<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>

<meta charset="utf-8">
<meta name="generator" content="quarto-99.9.9">

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">

<meta name="author" content="J Andrés Gannon">
<meta name="author" content="Kerry Chavez">
<meta name="dcterms.date" content="2023-05-05">

<title>06 Figures</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
  { counter-reset: source-line 0; }
pre.numberSource code > span
  { position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
  { content: counter(source-line);
    position: relative; left: -1em; text-align: right; vertical-align: baseline;
    border: none; display: inline-block;
    -webkit-touch-callout: none; -webkit-user-select: none;
    -khtml-user-select: none; -moz-user-select: none;
    -ms-user-select: none; user-select: none;
    padding: 0 4px; width: 4em;
    color: #aaaaaa;
  }
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa;  padding-left: 4px; }
div.sourceCode
  {   }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
</style>


<script src="06_Figures_files/libs/clipboard/clipboard.min.js"></script>
<script src="06_Figures_files/libs/quarto-html/quarto.js"></script>
<script src="06_Figures_files/libs/quarto-html/popper.min.js"></script>
<script src="06_Figures_files/libs/quarto-html/tippy.umd.min.js"></script>
<script src="06_Figures_files/libs/quarto-html/anchor.min.js"></script>
<link href="06_Figures_files/libs/quarto-html/tippy.css" rel="stylesheet">
<link href="06_Figures_files/libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="06_Figures_files/libs/bootstrap/bootstrap.min.js"></script>
<link href="06_Figures_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="06_Figures_files/libs/bootstrap/bootstrap.min.css" rel="stylesheet">


<link rel="stylesheet" href="styles.css">
</head>

<body>

<header id="title-block-header" class="quarto-title-block default page-columns page-full">
  <div class="quarto-title-banner page-columns page-full">
    <div class="quarto-title column-body">
      <div class="quarto-title-block"><div><h1 class="title">06 Figures</h1><button type="button" class="btn code-tools-button" id="quarto-code-tools-source"><i class="bi"></i> Code</button></div></div>
                      </div>
  </div>
    
  
  <div class="quarto-title-meta">

      <div>
      <div class="quarto-title-meta-heading">Authors</div>
      <div class="quarto-title-meta-contents">
               <p>J Andrés Gannon </p>
               <p>Kerry Chavez </p>
            </div>
    </div>
      
      <div>
      <div class="quarto-title-meta-heading">Published</div>
      <div class="quarto-title-meta-contents">
        <p class="date">May 5, 2023</p>
      </div>
    </div>
      
    </div>
    
  
  </header><div id="quarto-content" class="page-columns page-rows-contents page-layout-article">
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
  <nav id="TOC" role="doc-toc">
    <h2 id="toc-title">Table of contents</h2>
   
  <ul>
  <li><a href="#set-up" id="toc-set-up" class="nav-link active" data-scroll-target="#set-up">Set up</a></li>
  <li><a href="#timeline" id="toc-timeline" class="nav-link" data-scroll-target="#timeline">Timeline</a></li>
  <li><a href="#sample-table" id="toc-sample-table" class="nav-link" data-scroll-target="#sample-table">Sample table</a></li>
  <li><a href="#nested-dependencies" id="toc-nested-dependencies" class="nav-link" data-scroll-target="#nested-dependencies">Nested dependencies</a></li>
  <li><a href="#nested-gulf-war" id="toc-nested-gulf-war" class="nav-link" data-scroll-target="#nested-gulf-war">Nested Gulf War</a></li>
  <li><a href="#map" id="toc-map" class="nav-link" data-scroll-target="#map">Map</a></li>
  <li><a href="#network-plot" id="toc-network-plot" class="nav-link" data-scroll-target="#network-plot">Network plot</a>
  <ul class="collapse">
  <li><a href="#gulf-war" id="toc-gulf-war" class="nav-link" data-scroll-target="#gulf-war">Gulf War</a></li>
  <li><a href="#afghanistan-war" id="toc-afghanistan-war" class="nav-link" data-scroll-target="#afghanistan-war">Afghanistan war</a></li>
  <li><a href="#syrian-war" id="toc-syrian-war" class="nav-link" data-scroll-target="#syrian-war">Syrian War</a></li>
  <li><a href="#combine-all-plots" id="toc-combine-all-plots" class="nav-link" data-scroll-target="#combine-all-plots">Combine all plots</a></li>
  </ul></li>
  </ul>
</nav>
</div>
<main class="content quarto-banner-title-block" id="quarto-document-content">




<section id="set-up" class="level1">
<h1>Set up</h1>
<div class="cell" data-hash="06_Figures_cache/html/unnamed-chunk-1_8c4e70870959e16d0ff3b17218726201">

</div>
<p>Load the cleaned intervention data that only includes youngest children</p>
<div class="cell" data-hash="06_Figures_cache/html/unnamed-chunk-2_716b36994ef86e62d3643118d8121093">

</div>
</section>
<section id="timeline" class="level1">
<h1>Timeline</h1>
<p>How have US operations changed over time?</p>
<div class="cell" data-hash="06_Figures_cache/html/unnamed-chunk-3_d72e425d535cda31603e96f068e9ce4b">
<div class="cell-output-display">
<p><img src="06_Figures_files/figure-html/unnamed-chunk-3-1.png" class="img-fluid" width="672"></p>
</div>
</div>
</section>
<section id="sample-table" class="level1">
<h1>Sample table</h1>
<p>Sample table showing a sample of operations and some relevant covariates.</p>
<div class="cell" data-hash="06_Figures_cache/html/unnamed-chunk-4_75fc63545136ef0fa00c1c64c6e6be55">

</div>
</section>
<section id="nested-dependencies" class="level1">
<h1>Nested dependencies</h1>
<div class="cell" data-hash="06_Figures_cache/html/unnamed-chunk-5_6416eb273d99f112f5680ce91196f97f">
<div class="cell-output-display">
<p><img src="06_Figures_files/figure-html/unnamed-chunk-5-1.png" class="img-fluid" width="672"></p>
</div>
</div>
</section>
<section id="nested-gulf-war" class="level1">
<h1>Nested Gulf War</h1>
<div class="cell" data-hash="06_Figures_cache/html/unnamed-chunk-6_5aae58dc2b831df007d9a33800431844">

</div>
</section>
<section id="map" class="level1">
<h1>Map</h1>
<div class="cell" data-hash="06_Figures_cache/html/unnamed-chunk-7_cec864d4f6e669077d9db9bdad958ff7">
<div class="cell-output-display">
<p><img src="06_Figures_files/figure-html/unnamed-chunk-7-1.png" class="img-fluid" width="672"></p>
</div>
</div>
</section>
<section id="network-plot" class="level1">
<h1>Network plot</h1>
<div class="cell" data-hash="06_Figures_cache/html/unnamed-chunk-8_1b0af1638b90d32879fee49b62efa1ff">

</div>
<section id="gulf-war" class="level2">
<h2 class="anchored" data-anchor-id="gulf-war">Gulf War</h2>
<div class="cell" data-hash="06_Figures_cache/html/unnamed-chunk-9_f3bd145ccb51e11a0531d5a06670c6f7">

</div>
</section>
<section id="afghanistan-war" class="level2">
<h2 class="anchored" data-anchor-id="afghanistan-war">Afghanistan war</h2>
<div class="cell" data-hash="06_Figures_cache/html/unnamed-chunk-10_7974d3ac76b2b8d21d785f4bf30d21b3">

</div>
</section>
<section id="syrian-war" class="level2">
<h2 class="anchored" data-anchor-id="syrian-war">Syrian War</h2>
<div class="cell" data-hash="06_Figures_cache/html/unnamed-chunk-11_7d1f37cde17aa3e066c619234b39b61e">
<div class="cell-output cell-output-stdout">
<pre><code> [1] "Al-Sanadid Forces"        "Asayish"                 
 [3] "Australia"                "Denmark"                 
 [5] "Federal Security Forces"  "France"                  
 [7] "Free Syrian Army"         "Germany"                 
 [9] "Hezbollah"                "Iraq"                    
[11] "Iraqi Kurdistan"          "Jordan"                  
[13] "Netherlands"              "Norway"                  
[15] "Peshmerga"                "Russia"                  
[17] "Sinjar Resistance Units"  "Sootoro"                 
[19] "Syria"                    "Syriac Union Party"      
[21] "Syrian Democratic Forces" "Syrian Kurdistan"        
[23] "Syrian Opposition"        "Syrian rebels"           
[25] "Turkey"                   "United Kingdom"          
[27] "United States"            "YBŞ"                     
[29] "YJÊ"                      "YPG"                     
[31] "YPJ"                     </code></pre>
</div>
</div>
</section>
<section id="combine-all-plots" class="level2">
<h2 class="anchored" data-anchor-id="combine-all-plots">Combine all plots</h2>
<div class="cell" data-hash="06_Figures_cache/html/unnamed-chunk-12_618e90a266cda15f16d59f4c59513625">
<div class="cell-output-display">
<p><img src="06_Figures_files/figure-html/unnamed-chunk-12-1.png" class="img-fluid" width="672"></p>
</div>
</div>
<!-- -->

</section>
</section>

</main>
<!-- /main column -->
<script id="quarto-html-after-body" type="application/javascript">
window.document.addEventListener("DOMContentLoaded", function (event) {
  const icon = "";
  const anchorJS = new window.AnchorJS();
  anchorJS.options = {
    placement: 'right',
    icon: icon
  };
  anchorJS.add('.anchored');
  const clipboard = new window.ClipboardJS('.code-copy-button', {
    target: function(trigger) {
      return trigger.previousElementSibling;
    }
  });
  clipboard.on('success', function(e) {
    // button target
    const button = e.trigger;
    // don't keep focus
    button.blur();
    // flash "checked"
    button.classList.add('code-copy-button-checked');
    var currentTitle = button.getAttribute("title");
    button.setAttribute("title", "Copied!");
    setTimeout(function() {
      button.setAttribute("title", currentTitle);
      button.classList.remove('code-copy-button-checked');
    }, 1000);
    // clear code selection
    e.clearSelection();
  });
  const viewSource = window.document.getElementById('quarto-view-source') ||
                     window.document.getElementById('quarto-code-tools-source');
  if (viewSource) {
    const sourceUrl = viewSource.getAttribute("data-quarto-source-url");
    viewSource.addEventListener("click", function(e) {
      if (sourceUrl) {
        // rstudio viewer pane
        if (/\bcapabilities=\b/.test(window.location)) {
          window.open(sourceUrl);
        } else {
          window.location.href = sourceUrl;
        }
      } else {
        const modal = new bootstrap.Modal(document.getElementById('quarto-embedded-source-code-modal'));
        modal.show();
      }
      return false;
    });
  }
  function toggleCodeHandler(show) {
    return function(e) {
      const detailsSrc = window.document.querySelectorAll(".cell > details > .sourceCode");
      for (let i=0; i<detailsSrc.length; i++) {
        const details = detailsSrc[i].parentElement;
        if (show) {
          details.open = true;
        } else {
          details.removeAttribute("open");
        }
      }
      const cellCodeDivs = window.document.querySelectorAll(".cell > .sourceCode");
      const fromCls = show ? "hidden" : "unhidden";
      const toCls = show ? "unhidden" : "hidden";
      for (let i=0; i<cellCodeDivs.length; i++) {
        const codeDiv = cellCodeDivs[i];
        if (codeDiv.classList.contains(fromCls)) {
          codeDiv.classList.remove(fromCls);
          codeDiv.classList.add(toCls);
        } 
      }
      return false;
    }
  }
  const hideAllCode = window.document.getElementById("quarto-hide-all-code");
  if (hideAllCode) {
    hideAllCode.addEventListener("click", toggleCodeHandler(false));
  }
  const showAllCode = window.document.getElementById("quarto-show-all-code");
  if (showAllCode) {
    showAllCode.addEventListener("click", toggleCodeHandler(true));
  }
  function tippyHover(el, contentFn) {
    const config = {
      allowHTML: true,
      content: contentFn,
      maxWidth: 500,
      delay: 100,
      arrow: false,
      appendTo: function(el) {
          return el.parentElement;
      },
      interactive: true,
      interactiveBorder: 10,
      theme: 'quarto',
      placement: 'bottom-start'
    };
    window.tippy(el, config); 
  }
  const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
  for (var i=0; i<noterefs.length; i++) {
    const ref = noterefs[i];
    tippyHover(ref, function() {
      let href = ref.getAttribute('href');
      try { href = new URL(href).hash; } catch {}
      const id = href.replace(/^#\/?/, "");
      const note = window.document.getElementById(id);
      return note.innerHTML;
    });
  }
  var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
  for (var i=0; i<bibliorefs.length; i++) {
    const ref = bibliorefs[i];
    const cites = ref.parentNode.getAttribute('data-cites').split(' ');
    tippyHover(ref, function() {
      var popup = window.document.createElement('div');
      cites.forEach(function(cite) {
        var citeDiv = window.document.createElement('div');
        citeDiv.classList.add('hanging-indent');
        citeDiv.classList.add('csl-entry');
        var biblioDiv = window.document.getElementById('ref-' + cite);
        if (biblioDiv) {
          citeDiv.innerHTML = biblioDiv.innerHTML;
        }
        popup.appendChild(citeDiv);
      });
      return popup.innerHTML;
    });
  }
});
</script><div class="modal fade" id="quarto-embedded-source-code-modal" tabindex="-1" aria-labelledby="quarto-embedded-source-code-modal-label" aria-hidden="true"><div class="modal-dialog modal-dialog-scrollable"><div class="modal-content"><div class="modal-header"><h5 class="modal-title" id="quarto-embedded-source-code-modal-label">Source Code</h5><button class="btn-close" data-bs-dismiss="modal"></button></div><div class="modal-body"><div class="">
<div class="sourceCode" id="cb2" data-shortcodes="false"><pre class="sourceCode markdown code-with-copy"><code class="sourceCode markdown"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co">---</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="an">title:</span><span class="co"> "06 Figures"</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="an">author:</span></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="co">  - J Andrés Gannon</span></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a><span class="co">  - Kerry Chavez</span></span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a><span class="an">format:</span></span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a><span class="co">  html:</span></span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a><span class="co">    title-block-banner: true</span></span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a><span class="co">    toc: true</span></span>
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a><span class="co">    toc-location: right</span></span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a><span class="co">    html-math-method: katex</span></span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a><span class="co">    css: styles.css</span></span>
<span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a><span class="co">    citations-hover: true</span></span>
<span id="cb2-14"><a href="#cb2-14" aria-hidden="true" tabindex="-1"></a><span class="co">    footnotes-hover: true</span></span>
<span id="cb2-15"><a href="#cb2-15" aria-hidden="true" tabindex="-1"></a><span class="co">    code-tools: true</span></span>
<span id="cb2-16"><a href="#cb2-16" aria-hidden="true" tabindex="-1"></a><span class="co">    code-fold: true</span></span>
<span id="cb2-17"><a href="#cb2-17" aria-hidden="true" tabindex="-1"></a><span class="co">    code-summary: "Show the code"</span></span>
<span id="cb2-18"><a href="#cb2-18" aria-hidden="true" tabindex="-1"></a><span class="co">    code-overflow: wrap</span></span>
<span id="cb2-19"><a href="#cb2-19" aria-hidden="true" tabindex="-1"></a><span class="co">    code-copy: true</span></span>
<span id="cb2-20"><a href="#cb2-20" aria-hidden="true" tabindex="-1"></a><span class="an">editor:</span><span class="co"> visual</span></span>
<span id="cb2-21"><a href="#cb2-21" aria-hidden="true" tabindex="-1"></a><span class="an">execute:</span></span>
<span id="cb2-22"><a href="#cb2-22" aria-hidden="true" tabindex="-1"></a><span class="co">  echo: false</span></span>
<span id="cb2-23"><a href="#cb2-23" aria-hidden="true" tabindex="-1"></a><span class="co">  warning: false</span></span>
<span id="cb2-24"><a href="#cb2-24" aria-hidden="true" tabindex="-1"></a><span class="co">  cache: true</span></span>
<span id="cb2-25"><a href="#cb2-25" aria-hidden="true" tabindex="-1"></a><span class="an">date:</span><span class="co"> "`r format(Sys.Date(), '%B %d, %Y')`"</span></span>
<span id="cb2-26"><a href="#cb2-26" aria-hidden="true" tabindex="-1"></a><span class="co">---</span></span>
<span id="cb2-27"><a href="#cb2-27" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-28"><a href="#cb2-28" aria-hidden="true" tabindex="-1"></a><span class="fu"># Set up</span></span>
<span id="cb2-29"><a href="#cb2-29" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-32"><a href="#cb2-32" aria-hidden="true" tabindex="-1"></a><span class="in">```{r}</span></span>
<span id="cb2-33"><a href="#cb2-33" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(magrittr)</span>
<span id="cb2-34"><a href="#cb2-34" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(tidyverse)</span>
<span id="cb2-35"><a href="#cb2-35" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(ggplot2)</span>
<span id="cb2-36"><a href="#cb2-36" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(kableExtra)</span>
<span id="cb2-37"><a href="#cb2-37" aria-hidden="true" tabindex="-1"></a><span class="in">```</span></span>
<span id="cb2-38"><a href="#cb2-38" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-39"><a href="#cb2-39" aria-hidden="true" tabindex="-1"></a>Load the cleaned intervention data that only includes youngest children</span>
<span id="cb2-40"><a href="#cb2-40" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-43"><a href="#cb2-43" aria-hidden="true" tabindex="-1"></a><span class="in">```{r}</span></span>
<span id="cb2-44"><a href="#cb2-44" aria-hidden="true" tabindex="-1"></a><span class="co"># New data</span></span>
<span id="cb2-45"><a href="#cb2-45" aria-hidden="true" tabindex="-1"></a>df_interv <span class="ot">&lt;-</span> <span class="fu">read.csv</span>(<span class="fu">paste0</span>(here<span class="sc">::</span><span class="fu">here</span>(), <span class="st">"/data/"</span>,<span class="st">"MONSTr.csv"</span>))</span>
<span id="cb2-46"><a href="#cb2-46" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-47"><a href="#cb2-47" aria-hidden="true" tabindex="-1"></a><span class="co"># Prior data</span></span>
<span id="cb2-48"><a href="#cb2-48" aria-hidden="true" tabindex="-1"></a>icb <span class="ot">&lt;-</span> <span class="fu">read.csv</span>(<span class="fu">paste0</span>(here<span class="sc">::</span><span class="fu">here</span>(),<span class="st">"/inst/extdata/icb2v12.csv"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-49"><a href="#cb2-49" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(yrtrig <span class="sc">&gt;=</span> <span class="dv">1989</span> <span class="sc">&amp;</span></span>
<span id="cb2-50"><a href="#cb2-50" aria-hidden="true" tabindex="-1"></a>                  actor <span class="sc">==</span> <span class="st">"USA"</span>)</span>
<span id="cb2-51"><a href="#cb2-51" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-52"><a href="#cb2-52" aria-hidden="true" tabindex="-1"></a>imi <span class="ot">&lt;-</span> <span class="fu">read.csv</span>(<span class="fu">paste0</span>(here<span class="sc">::</span><span class="fu">here</span>(),<span class="st">"/inst/extdata/IMI/IMI_dataset.csv"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-53"><a href="#cb2-53" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(start <span class="sc">&gt;=</span> <span class="dv">19890101</span> <span class="sc">&amp;</span></span>
<span id="cb2-54"><a href="#cb2-54" aria-hidden="true" tabindex="-1"></a>                  intervener <span class="sc">==</span> <span class="dv">2</span>)</span>
<span id="cb2-55"><a href="#cb2-55" aria-hidden="true" tabindex="-1"></a>imi<span class="sc">$</span>start <span class="ot">&lt;-</span> <span class="fu">gsub</span>(<span class="st">'.{4}$'</span>, <span class="st">''</span>, imi<span class="sc">$</span>start)</span>
<span id="cb2-56"><a href="#cb2-56" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-57"><a href="#cb2-57" aria-hidden="true" tabindex="-1"></a>mids <span class="ot">&lt;-</span> <span class="fu">read.csv</span>(<span class="fu">paste0</span>(here<span class="sc">::</span><span class="fu">here</span>(),<span class="st">"/inst/extdata/MIDs/MIDs_dispute-participants.csv"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-58"><a href="#cb2-58" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(styear <span class="sc">&gt;=</span> <span class="dv">1989</span> <span class="sc">&amp;</span></span>
<span id="cb2-59"><a href="#cb2-59" aria-hidden="true" tabindex="-1"></a>                  ccode <span class="sc">==</span> <span class="dv">2</span>)</span>
<span id="cb2-60"><a href="#cb2-60" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-61"><a href="#cb2-61" aria-hidden="true" tabindex="-1"></a>mips <span class="ot">&lt;-</span> <span class="fu">read.csv</span>(<span class="fu">paste0</span>(here<span class="sc">::</span><span class="fu">here</span>(),<span class="st">"/inst/extdata/MIPS/MIPS_dataset.csv"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-62"><a href="#cb2-62" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(styr <span class="sc">&gt;=</span> <span class="dv">1989</span> <span class="sc">&amp;</span></span>
<span id="cb2-63"><a href="#cb2-63" aria-hidden="true" tabindex="-1"></a>                  MP <span class="sc">==</span> <span class="dv">2</span>)</span>
<span id="cb2-64"><a href="#cb2-64" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-65"><a href="#cb2-65" aria-hidden="true" tabindex="-1"></a>mip <span class="ot">&lt;-</span> readstata13<span class="sc">::</span><span class="fu">read.dta13</span>(<span class="fu">paste0</span>(here<span class="sc">::</span><span class="fu">here</span>(),<span class="st">"/inst/extdata/MIP/MIPDataKushiToft.dta"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-66"><a href="#cb2-66" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(styear <span class="sc">&gt;=</span> <span class="dv">1989</span> <span class="sc">&amp;</span></span>
<span id="cb2-67"><a href="#cb2-67" aria-hidden="true" tabindex="-1"></a>                  RemoveCase <span class="sc">==</span> <span class="dv">0</span>)</span>
<span id="cb2-68"><a href="#cb2-68" aria-hidden="true" tabindex="-1"></a>  </span>
<span id="cb2-69"><a href="#cb2-69" aria-hidden="true" tabindex="-1"></a>prio <span class="ot">&lt;-</span> <span class="fu">read.csv</span>(<span class="fu">paste0</span>(here<span class="sc">::</span><span class="fu">here</span>(),<span class="st">"/inst/extdata/PRIO/UCDP-PRIO_armed_conflict_dataset.csv"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-70"><a href="#cb2-70" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(year <span class="sc">&gt;=</span> <span class="dv">1989</span> <span class="sc">&amp;</span></span>
<span id="cb2-71"><a href="#cb2-71" aria-hidden="true" tabindex="-1"></a>                  side_a_id <span class="sc">==</span> <span class="dv">3</span>) <span class="co"># PRIO does not use the GW identifier. It is confirmed that this refers to the USA</span></span>
<span id="cb2-72"><a href="#cb2-72" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-73"><a href="#cb2-73" aria-hidden="true" tabindex="-1"></a>rand <span class="ot">&lt;-</span> <span class="fu">read.csv</span>(<span class="fu">paste0</span>(here<span class="sc">::</span><span class="fu">here</span>(),<span class="st">"/inst/extdata/rand_interventionlist.csv"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-74"><a href="#cb2-74" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(incident_start_year <span class="sc">&gt;=</span> <span class="dv">1989</span>)</span>
<span id="cb2-75"><a href="#cb2-75" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-76"><a href="#cb2-76" aria-hidden="true" tabindex="-1"></a>allen_17 <span class="ot">&lt;-</span> readstata13<span class="sc">::</span><span class="fu">read.dta13</span>(<span class="fu">paste0</span>(here<span class="sc">::</span><span class="fu">here</span>(), <span class="st">"/inst/extdata/AllenMtzMachainAerialBombingData2016CMPS.dta"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-77"><a href="#cb2-77" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(year <span class="sc">&gt;=</span> <span class="dv">1989</span>,</span>
<span id="cb2-78"><a href="#cb2-78" aria-hidden="true" tabindex="-1"></a>                ccode1 <span class="sc">==</span> <span class="dv">2</span>)</span>
<span id="cb2-79"><a href="#cb2-79" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-80"><a href="#cb2-80" aria-hidden="true" tabindex="-1"></a>horowitz_01 <span class="ot">&lt;-</span> foreign<span class="sc">::</span><span class="fu">read.dta</span>(<span class="fu">paste0</span>(here<span class="sc">::</span><span class="fu">here</span>(), <span class="st">"/inst/extdata/jcr01.dta"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-81"><a href="#cb2-81" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(attacker <span class="sc">%in%</span> <span class="fu">c</span>(<span class="st">'United States'</span>, <span class="st">'Allies'</span>, <span class="st">'U.S./Britain'</span>, <span class="st">'NATO'</span>, <span class="st">'US'</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-82"><a href="#cb2-82" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">mutate</span>(<span class="at">date =</span> dplyr<span class="sc">::</span><span class="fu">recode</span>(date,</span>
<span id="cb2-83"><a href="#cb2-83" aria-hidden="true" tabindex="-1"></a>                                     <span class="st">'1944-1945'</span> <span class="ot">=</span> <span class="st">"1944"</span>,</span>
<span id="cb2-84"><a href="#cb2-84" aria-hidden="true" tabindex="-1"></a>                                     <span class="st">'1942-1944'</span> <span class="ot">=</span> <span class="st">"1942"</span>,</span>
<span id="cb2-85"><a href="#cb2-85" aria-hidden="true" tabindex="-1"></a>                                     <span class="st">'Aug. 1945'</span> <span class="ot">=</span> <span class="st">"1945"</span>,</span>
<span id="cb2-86"><a href="#cb2-86" aria-hidden="true" tabindex="-1"></a>                                     <span class="st">'1965-1968'</span> <span class="ot">=</span> <span class="st">"1965"</span>,</span>
<span id="cb2-87"><a href="#cb2-87" aria-hidden="true" tabindex="-1"></a>                                     <span class="st">'1950-1951'</span> <span class="ot">=</span> <span class="st">"1950"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-88"><a href="#cb2-88" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">mutate</span>(<span class="at">date =</span> <span class="fu">as.numeric</span>(date)) <span class="sc">%&gt;%</span></span>
<span id="cb2-89"><a href="#cb2-89" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(date <span class="sc">&gt;=</span> <span class="dv">1989</span>)</span>
<span id="cb2-90"><a href="#cb2-90" aria-hidden="true" tabindex="-1"></a><span class="in">```</span></span>
<span id="cb2-91"><a href="#cb2-91" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-92"><a href="#cb2-92" aria-hidden="true" tabindex="-1"></a><span class="fu"># Timeline</span></span>
<span id="cb2-93"><a href="#cb2-93" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-94"><a href="#cb2-94" aria-hidden="true" tabindex="-1"></a>How have US operations changed over time?</span>
<span id="cb2-95"><a href="#cb2-95" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-98"><a href="#cb2-98" aria-hidden="true" tabindex="-1"></a><span class="in">```{r}</span></span>
<span id="cb2-99"><a href="#cb2-99" aria-hidden="true" tabindex="-1"></a>df_interv <span class="sc">%&gt;%</span></span>
<span id="cb2-100"><a href="#cb2-100" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(start_date,</span>
<span id="cb2-101"><a href="#cb2-101" aria-hidden="true" tabindex="-1"></a>                dplyr<span class="sc">::</span><span class="fu">starts_with</span>(<span class="st">"means_"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-102"><a href="#cb2-102" aria-hidden="true" tabindex="-1"></a>  tidyr<span class="sc">::</span><span class="fu">pivot_longer</span>(<span class="at">cols =</span> dplyr<span class="sc">::</span><span class="fu">starts_with</span>(<span class="st">"means_"</span>),</span>
<span id="cb2-103"><a href="#cb2-103" aria-hidden="true" tabindex="-1"></a>                      <span class="at">names_to =</span> <span class="st">"means"</span>,</span>
<span id="cb2-104"><a href="#cb2-104" aria-hidden="true" tabindex="-1"></a>                      <span class="at">values_to =</span> <span class="st">"used"</span>) <span class="sc">%&gt;%</span></span>
<span id="cb2-105"><a href="#cb2-105" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">mutate</span>(<span class="at">means =</span> stringr<span class="sc">::</span><span class="fu">str_remove</span>(means, <span class="st">"means_"</span>),</span>
<span id="cb2-106"><a href="#cb2-106" aria-hidden="true" tabindex="-1"></a>                <span class="at">used =</span> <span class="fu">as.numeric</span>(used),</span>
<span id="cb2-107"><a href="#cb2-107" aria-hidden="true" tabindex="-1"></a>                <span class="at">start_date =</span> <span class="fu">as.Date</span>(start_date)) <span class="sc">%&gt;%</span></span>
<span id="cb2-108"><a href="#cb2-108" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">group_by</span>(means) <span class="sc">%&gt;%</span></span>
<span id="cb2-109"><a href="#cb2-109" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">arrange</span>(start_date) <span class="sc">%&gt;%</span></span>
<span id="cb2-110"><a href="#cb2-110" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">mutate</span>(<span class="at">used =</span> dplyr<span class="sc">::</span><span class="fu">coalesce</span>(used, <span class="dv">0</span>),</span>
<span id="cb2-111"><a href="#cb2-111" aria-hidden="true" tabindex="-1"></a>                <span class="at">means_cum =</span> <span class="fu">cumsum</span>(used),</span>
<span id="cb2-112"><a href="#cb2-112" aria-hidden="true" tabindex="-1"></a>                <span class="at">means =</span> <span class="fu">recode</span>(means,</span>
<span id="cb2-113"><a href="#cb2-113" aria-hidden="true" tabindex="-1"></a>                               <span class="st">"groundtroops"</span> <span class="ot">=</span> <span class="st">"Ground troops"</span>,</span>
<span id="cb2-114"><a href="#cb2-114" aria-hidden="true" tabindex="-1"></a>                               <span class="st">"aerialbombing"</span> <span class="ot">=</span> <span class="st">"Aerial bombing"</span>,</span>
<span id="cb2-115"><a href="#cb2-115" aria-hidden="true" tabindex="-1"></a>                               <span class="st">"closeairsupport"</span> <span class="ot">=</span> <span class="st">"Close air support"</span>,</span>
<span id="cb2-116"><a href="#cb2-116" aria-hidden="true" tabindex="-1"></a>                               <span class="st">"paramilitary"</span> <span class="ot">=</span> <span class="st">"Paramilitary"</span>,</span>
<span id="cb2-117"><a href="#cb2-117" aria-hidden="true" tabindex="-1"></a>                               <span class="st">"drones"</span> <span class="ot">=</span> <span class="st">"Drones"</span>,</span>
<span id="cb2-118"><a href="#cb2-118" aria-hidden="true" tabindex="-1"></a>                               <span class="st">"cruisemissiles"</span> <span class="ot">=</span> <span class="st">"Cruise missiles"</span>,</span>
<span id="cb2-119"><a href="#cb2-119" aria-hidden="true" tabindex="-1"></a>                               <span class="st">"airtoair"</span> <span class="ot">=</span> <span class="st">"Air to air"</span>),</span>
<span id="cb2-120"><a href="#cb2-120" aria-hidden="true" tabindex="-1"></a>                <span class="at">label =</span> dplyr<span class="sc">::</span><span class="fu">if_else</span>(start_date <span class="sc">==</span> <span class="fu">max</span>(start_date, <span class="at">na.rm =</span> <span class="cn">TRUE</span>),</span>
<span id="cb2-121"><a href="#cb2-121" aria-hidden="true" tabindex="-1"></a>                                       <span class="fu">as.character</span>(means),</span>
<span id="cb2-122"><a href="#cb2-122" aria-hidden="true" tabindex="-1"></a>                                       <span class="cn">NA_character_</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-123"><a href="#cb2-123" aria-hidden="true" tabindex="-1"></a>  <span class="fu">ggplot</span>(<span class="fu">aes</span>(<span class="at">x =</span> start_date,</span>
<span id="cb2-124"><a href="#cb2-124" aria-hidden="true" tabindex="-1"></a>             <span class="at">y =</span> means_cum,</span>
<span id="cb2-125"><a href="#cb2-125" aria-hidden="true" tabindex="-1"></a>             <span class="at">group =</span> means,</span>
<span id="cb2-126"><a href="#cb2-126" aria-hidden="true" tabindex="-1"></a>             <span class="at">color =</span> means)) <span class="sc">+</span></span>
<span id="cb2-127"><a href="#cb2-127" aria-hidden="true" tabindex="-1"></a>  <span class="fu">geom_line</span>(<span class="fu">aes</span>(<span class="at">fill =</span> <span class="fu">factor</span>(label))) <span class="sc">+</span></span>
<span id="cb2-128"><a href="#cb2-128" aria-hidden="true" tabindex="-1"></a>  geomtextpath<span class="sc">::</span><span class="fu">geom_textvline</span>(<span class="at">xintercept =</span> <span class="fu">as.Date</span>(<span class="st">"1990-08-02"</span>),</span>
<span id="cb2-129"><a href="#cb2-129" aria-hidden="true" tabindex="-1"></a>                               <span class="at">label =</span> <span class="st">"Gulf War"</span>,</span>
<span id="cb2-130"><a href="#cb2-130" aria-hidden="true" tabindex="-1"></a>                               <span class="at">hjust =</span> <span class="fl">0.8</span>,</span>
<span id="cb2-131"><a href="#cb2-131" aria-hidden="true" tabindex="-1"></a>                               <span class="at">linetype =</span> <span class="dv">2</span>,</span>
<span id="cb2-132"><a href="#cb2-132" aria-hidden="true" tabindex="-1"></a>                               <span class="at">color =</span> <span class="st">"darkslategray"</span>) <span class="sc">+</span></span>
<span id="cb2-133"><a href="#cb2-133" aria-hidden="true" tabindex="-1"></a>  geomtextpath<span class="sc">::</span><span class="fu">geom_textvline</span>(<span class="at">xintercept =</span> <span class="fu">as.Date</span>(<span class="st">"1998-02-01"</span>),</span>
<span id="cb2-134"><a href="#cb2-134" aria-hidden="true" tabindex="-1"></a>                               <span class="at">label =</span> <span class="st">"Kosovo War"</span>,</span>
<span id="cb2-135"><a href="#cb2-135" aria-hidden="true" tabindex="-1"></a>                               <span class="at">hjust =</span> <span class="fl">0.8</span>, </span>
<span id="cb2-136"><a href="#cb2-136" aria-hidden="true" tabindex="-1"></a>                               <span class="at">linetype =</span> <span class="dv">2</span>,</span>
<span id="cb2-137"><a href="#cb2-137" aria-hidden="true" tabindex="-1"></a>                               <span class="at">color =</span> <span class="st">"darkslategray"</span>) <span class="sc">+</span></span>
<span id="cb2-138"><a href="#cb2-138" aria-hidden="true" tabindex="-1"></a>  geomtextpath<span class="sc">::</span><span class="fu">geom_textvline</span>(<span class="at">xintercept =</span> <span class="fu">as.Date</span>(<span class="st">"2001-10-07"</span>), </span>
<span id="cb2-139"><a href="#cb2-139" aria-hidden="true" tabindex="-1"></a>                               <span class="at">label =</span> <span class="st">"Afghanistan War"</span>, </span>
<span id="cb2-140"><a href="#cb2-140" aria-hidden="true" tabindex="-1"></a>                               <span class="at">hjust =</span> <span class="fl">0.8</span>, </span>
<span id="cb2-141"><a href="#cb2-141" aria-hidden="true" tabindex="-1"></a>                               <span class="at">linetype =</span> <span class="dv">2</span>, </span>
<span id="cb2-142"><a href="#cb2-142" aria-hidden="true" tabindex="-1"></a>                               <span class="at">color =</span> <span class="st">"darkslategray"</span>) <span class="sc">+</span></span>
<span id="cb2-143"><a href="#cb2-143" aria-hidden="true" tabindex="-1"></a>  geomtextpath<span class="sc">::</span><span class="fu">geom_textvline</span>(<span class="at">xintercept =</span> <span class="fu">as.Date</span>(<span class="st">"2003-03-20"</span>), </span>
<span id="cb2-144"><a href="#cb2-144" aria-hidden="true" tabindex="-1"></a>                               <span class="at">label =</span> <span class="st">"Iraq War"</span>, </span>
<span id="cb2-145"><a href="#cb2-145" aria-hidden="true" tabindex="-1"></a>                               <span class="at">hjust =</span> <span class="fl">0.75</span>, </span>
<span id="cb2-146"><a href="#cb2-146" aria-hidden="true" tabindex="-1"></a>                               <span class="at">linetype =</span> <span class="dv">2</span>, </span>
<span id="cb2-147"><a href="#cb2-147" aria-hidden="true" tabindex="-1"></a>                               <span class="at">color =</span> <span class="st">"darkslategray"</span>) <span class="sc">+</span></span>
<span id="cb2-148"><a href="#cb2-148" aria-hidden="true" tabindex="-1"></a>  geomtextpath<span class="sc">::</span><span class="fu">geom_textvline</span>(<span class="at">xintercept =</span> <span class="fu">as.Date</span>(<span class="st">"2011-03-19"</span>), </span>
<span id="cb2-149"><a href="#cb2-149" aria-hidden="true" tabindex="-1"></a>                               <span class="at">label =</span> <span class="st">"Libyan Intervention"</span>, </span>
<span id="cb2-150"><a href="#cb2-150" aria-hidden="true" tabindex="-1"></a>                               <span class="at">hjust =</span> <span class="fl">0.9</span>, </span>
<span id="cb2-151"><a href="#cb2-151" aria-hidden="true" tabindex="-1"></a>                               <span class="at">linetype =</span> <span class="dv">2</span>, </span>
<span id="cb2-152"><a href="#cb2-152" aria-hidden="true" tabindex="-1"></a>                               <span class="at">color =</span> <span class="st">"darkslategray"</span>) <span class="sc">+</span></span>
<span id="cb2-153"><a href="#cb2-153" aria-hidden="true" tabindex="-1"></a>  geomtextpath<span class="sc">::</span><span class="fu">geom_textvline</span>(<span class="at">xintercept =</span> <span class="fu">as.Date</span>(<span class="st">"2014-09-22"</span>), </span>
<span id="cb2-154"><a href="#cb2-154" aria-hidden="true" tabindex="-1"></a>                               <span class="at">label =</span> <span class="st">"Syrian Civil War"</span>,</span>
<span id="cb2-155"><a href="#cb2-155" aria-hidden="true" tabindex="-1"></a>                               <span class="at">hjust =</span> <span class="fl">0.92</span>, </span>
<span id="cb2-156"><a href="#cb2-156" aria-hidden="true" tabindex="-1"></a>                               <span class="at">linetype =</span> <span class="dv">2</span>, </span>
<span id="cb2-157"><a href="#cb2-157" aria-hidden="true" tabindex="-1"></a>                               <span class="at">color =</span> <span class="st">"darkslategray"</span>) <span class="sc">+</span></span>
<span id="cb2-158"><a href="#cb2-158" aria-hidden="true" tabindex="-1"></a>  <span class="fu">geom_label</span>(<span class="fu">aes</span>(<span class="at">label =</span> label,</span>
<span id="cb2-159"><a href="#cb2-159" aria-hidden="true" tabindex="-1"></a>                 <span class="at">fill =</span> <span class="fu">factor</span>(label),</span>
<span id="cb2-160"><a href="#cb2-160" aria-hidden="true" tabindex="-1"></a>                 <span class="at">x =</span> <span class="fu">as.Date</span>(<span class="st">"2022-01-01"</span>)),</span>
<span id="cb2-161"><a href="#cb2-161" aria-hidden="true" tabindex="-1"></a>             <span class="at">size =</span> <span class="dv">3</span>,</span>
<span id="cb2-162"><a href="#cb2-162" aria-hidden="true" tabindex="-1"></a>             <span class="at">color =</span> <span class="st">"white"</span>,</span>
<span id="cb2-163"><a href="#cb2-163" aria-hidden="true" tabindex="-1"></a>             <span class="at">hjust =</span> <span class="st">"outward"</span>) <span class="sc">+</span></span>
<span id="cb2-164"><a href="#cb2-164" aria-hidden="true" tabindex="-1"></a>  <span class="fu">scale_fill_hue</span>(<span class="at">l =</span> <span class="dv">40</span>) <span class="sc">+</span></span>
<span id="cb2-165"><a href="#cb2-165" aria-hidden="true" tabindex="-1"></a>  <span class="fu">coord_cartesian</span>(<span class="at">clip =</span> <span class="st">"off"</span>) <span class="sc">+</span></span>
<span id="cb2-166"><a href="#cb2-166" aria-hidden="true" tabindex="-1"></a>  <span class="fu">scale_y_continuous</span>(<span class="at">breaks =</span> <span class="fu">seq</span>(<span class="dv">0</span>, <span class="dv">150</span>, <span class="dv">25</span>),</span>
<span id="cb2-167"><a href="#cb2-167" aria-hidden="true" tabindex="-1"></a>                     <span class="at">minor_breaks =</span> <span class="cn">NULL</span>,</span>
<span id="cb2-168"><a href="#cb2-168" aria-hidden="true" tabindex="-1"></a>                     <span class="at">expand =</span> <span class="fu">c</span>(<span class="dv">0</span>, <span class="dv">5</span>)) <span class="sc">+</span></span>
<span id="cb2-169"><a href="#cb2-169" aria-hidden="true" tabindex="-1"></a>  <span class="fu">scale_x_date</span>(<span class="at">date_labels =</span> <span class="st">"%Y"</span>,</span>
<span id="cb2-170"><a href="#cb2-170" aria-hidden="true" tabindex="-1"></a>               <span class="at">date_breaks =</span> <span class="st">"3 years"</span>,</span>
<span id="cb2-171"><a href="#cb2-171" aria-hidden="true" tabindex="-1"></a>               <span class="at">date_minor_breaks =</span> <span class="st">"1 year"</span>,</span>
<span id="cb2-172"><a href="#cb2-172" aria-hidden="true" tabindex="-1"></a>               <span class="at">limits =</span> <span class="fu">as.Date</span>(<span class="fu">c</span>(<span class="st">"1989-01-01"</span>, <span class="st">"2022-01-01"</span>)),</span>
<span id="cb2-173"><a href="#cb2-173" aria-hidden="true" tabindex="-1"></a>               <span class="at">expand =</span> <span class="fu">c</span>(<span class="dv">0</span>, <span class="dv">0</span>)) <span class="sc">+</span></span>
<span id="cb2-174"><a href="#cb2-174" aria-hidden="true" tabindex="-1"></a>  <span class="fu">theme_classic</span>() <span class="sc">+</span></span>
<span id="cb2-175"><a href="#cb2-175" aria-hidden="true" tabindex="-1"></a>  <span class="fu">theme</span>(<span class="at">text =</span> <span class="fu">element_text</span>(<span class="at">size =</span> <span class="dv">11</span>),</span>
<span id="cb2-176"><a href="#cb2-176" aria-hidden="true" tabindex="-1"></a>        <span class="at">legend.position =</span> <span class="st">"none"</span>,</span>
<span id="cb2-177"><a href="#cb2-177" aria-hidden="true" tabindex="-1"></a>        <span class="at">plot.margin =</span> <span class="fu">margin</span>(<span class="at">r =</span> <span class="dv">35</span>, <span class="at">l =</span> <span class="dv">5</span>, <span class="at">b =</span> <span class="dv">5</span>, <span class="at">t =</span> <span class="dv">5</span>, <span class="at">unit =</span> <span class="st">"mm"</span>)) <span class="sc">+</span></span>
<span id="cb2-178"><a href="#cb2-178" aria-hidden="true" tabindex="-1"></a>  <span class="fu">labs</span>(<span class="at">title =</span> <span class="st">"Cumulative Count of US Operations by Means (1989-2021)"</span>,</span>
<span id="cb2-179"><a href="#cb2-179" aria-hidden="true" tabindex="-1"></a>       <span class="at">x =</span> <span class="st">"Date"</span>,</span>
<span id="cb2-180"><a href="#cb2-180" aria-hidden="true" tabindex="-1"></a>       <span class="at">y =</span> <span class="st">"Count"</span>)</span>
<span id="cb2-181"><a href="#cb2-181" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-182"><a href="#cb2-182" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="at">height =</span> <span class="dv">4</span>, <span class="at">width =</span> <span class="dv">7</span>, <span class="fu">paste0</span>(here<span class="sc">::</span><span class="fu">here</span>(), <span class="st">"/paper/figures/"</span>,<span class="st">"fig_timeline1.png"</span>))</span>
<span id="cb2-183"><a href="#cb2-183" aria-hidden="true" tabindex="-1"></a><span class="in">```</span></span>
<span id="cb2-184"><a href="#cb2-184" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-185"><a href="#cb2-185" aria-hidden="true" tabindex="-1"></a><span class="fu"># Sample table</span></span>
<span id="cb2-186"><a href="#cb2-186" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-187"><a href="#cb2-187" aria-hidden="true" tabindex="-1"></a>Sample table showing a sample of operations and some relevant covariates.</span>
<span id="cb2-188"><a href="#cb2-188" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-191"><a href="#cb2-191" aria-hidden="true" tabindex="-1"></a><span class="in">```{r}</span></span>
<span id="cb2-192"><a href="#cb2-192" aria-hidden="true" tabindex="-1"></a>df_interv <span class="sc">%&gt;%</span></span>
<span id="cb2-193"><a href="#cb2-193" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(parent_name <span class="sc">==</span> <span class="st">"Iraq conflict (2003–present)"</span>) <span class="sc">%&gt;%</span></span>
<span id="cb2-194"><a href="#cb2-194" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">slice_sample</span>(<span class="at">n =</span> <span class="dv">8</span>) <span class="sc">%&gt;%</span></span>
<span id="cb2-195"><a href="#cb2-195" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(wikidata_name,</span>
<span id="cb2-196"><a href="#cb2-196" aria-hidden="true" tabindex="-1"></a>                means_aerialbombing, means_closeairsupport, means_groundtroops, means_paramilitary,</span>
<span id="cb2-197"><a href="#cb2-197" aria-hidden="true" tabindex="-1"></a>                lat, lon,</span>
<span id="cb2-198"><a href="#cb2-198" aria-hidden="true" tabindex="-1"></a>                start_date, end_date, duration, daysinto_parent,</span>
<span id="cb2-199"><a href="#cb2-199" aria-hidden="true" tabindex="-1"></a>                casualties_sideA, casualties_sideB, casualties_civilian) <span class="sc">%&gt;%</span></span>
<span id="cb2-200"><a href="#cb2-200" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">rename</span>(<span class="at">Operation =</span> wikidata_name,</span>
<span id="cb2-201"><a href="#cb2-201" aria-hidden="true" tabindex="-1"></a>                <span class="st">'Aerial bombing'</span> <span class="ot">=</span> means_aerialbombing,</span>
<span id="cb2-202"><a href="#cb2-202" aria-hidden="true" tabindex="-1"></a>                <span class="st">'CAS'</span> <span class="ot">=</span> means_closeairsupport,</span>
<span id="cb2-203"><a href="#cb2-203" aria-hidden="true" tabindex="-1"></a>                <span class="st">'Ground troops'</span> <span class="ot">=</span> means_groundtroops,</span>
<span id="cb2-204"><a href="#cb2-204" aria-hidden="true" tabindex="-1"></a>                <span class="st">'Paramilitary'</span> <span class="ot">=</span> means_paramilitary,</span>
<span id="cb2-205"><a href="#cb2-205" aria-hidden="true" tabindex="-1"></a>                <span class="at">Lat =</span> lat,</span>
<span id="cb2-206"><a href="#cb2-206" aria-hidden="true" tabindex="-1"></a>                <span class="at">Lon =</span> lon,</span>
<span id="cb2-207"><a href="#cb2-207" aria-hidden="true" tabindex="-1"></a>                <span class="at">Start =</span> start_date,</span>
<span id="cb2-208"><a href="#cb2-208" aria-hidden="true" tabindex="-1"></a>                <span class="at">End =</span> end_date,</span>
<span id="cb2-209"><a href="#cb2-209" aria-hidden="true" tabindex="-1"></a>                <span class="at">Duration =</span> duration,</span>
<span id="cb2-210"><a href="#cb2-210" aria-hidden="true" tabindex="-1"></a>                <span class="st">'Days into war'</span> <span class="ot">=</span> daysinto_parent,</span>
<span id="cb2-211"><a href="#cb2-211" aria-hidden="true" tabindex="-1"></a>                <span class="st">'Side A'</span> <span class="ot">=</span> casualties_sideA,</span>
<span id="cb2-212"><a href="#cb2-212" aria-hidden="true" tabindex="-1"></a>                <span class="st">'Side B'</span> <span class="ot">=</span> casualties_sideB,</span>
<span id="cb2-213"><a href="#cb2-213" aria-hidden="true" tabindex="-1"></a>                <span class="st">'Civilian'</span> <span class="ot">=</span> casualties_civilian) <span class="sc">%&gt;%</span></span>
<span id="cb2-214"><a href="#cb2-214" aria-hidden="true" tabindex="-1"></a>  <span class="fu">kable</span>(<span class="at">caption =</span> <span class="st">"Sample of Iraq War (2003) operations"</span>,</span>
<span id="cb2-215"><a href="#cb2-215" aria-hidden="true" tabindex="-1"></a>        <span class="at">label =</span> <span class="st">"tbl:comparison-sample"</span>,</span>
<span id="cb2-216"><a href="#cb2-216" aria-hidden="true" tabindex="-1"></a>        <span class="at">format =</span> <span class="st">"latex"</span>) <span class="sc">%&gt;%</span></span>
<span id="cb2-217"><a href="#cb2-217" aria-hidden="true" tabindex="-1"></a>  <span class="fu">kable_classic</span>() <span class="sc">%&gt;%</span></span>
<span id="cb2-218"><a href="#cb2-218" aria-hidden="true" tabindex="-1"></a>  <span class="fu">row_spec</span>(<span class="dv">0</span>, <span class="at">bold =</span> <span class="cn">TRUE</span>) <span class="sc">%&gt;%</span></span>
<span id="cb2-219"><a href="#cb2-219" aria-hidden="true" tabindex="-1"></a>  <span class="fu">add_header_above</span>(<span class="fu">c</span>(<span class="st">""</span>, <span class="st">"Means"</span> <span class="ot">=</span> <span class="dv">4</span>, <span class="st">"Location"</span> <span class="ot">=</span> <span class="dv">2</span>, <span class="st">"Time"</span> <span class="ot">=</span> <span class="dv">4</span>, <span class="st">"Casualties"</span> <span class="ot">=</span> <span class="dv">3</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-220"><a href="#cb2-220" aria-hidden="true" tabindex="-1"></a>  <span class="fu">kable_styling</span>(<span class="at">latex_options =</span> <span class="st">"scale_down"</span>) <span class="sc">%&gt;%</span></span>
<span id="cb2-221"><a href="#cb2-221" aria-hidden="true" tabindex="-1"></a>  kableExtra<span class="sc">::</span><span class="fu">save_kable</span>(<span class="at">file =</span> <span class="fu">paste0</span>(here<span class="sc">::</span><span class="fu">here</span>(), <span class="st">"/paper/figures/"</span>,<span class="st">"sample.tex"</span>))</span>
<span id="cb2-222"><a href="#cb2-222" aria-hidden="true" tabindex="-1"></a><span class="in">```</span></span>
<span id="cb2-223"><a href="#cb2-223" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-224"><a href="#cb2-224" aria-hidden="true" tabindex="-1"></a><span class="fu"># Nested dependencies</span></span>
<span id="cb2-225"><a href="#cb2-225" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-228"><a href="#cb2-228" aria-hidden="true" tabindex="-1"></a><span class="in">```{r}</span></span>
<span id="cb2-229"><a href="#cb2-229" aria-hidden="true" tabindex="-1"></a>dependency <span class="ot">&lt;-</span> <span class="fu">read.csv</span>(<span class="fu">paste0</span>(here<span class="sc">::</span><span class="fu">here</span>(), <span class="st">"/data/raw/"</span>,<span class="st">"03_newdata_childof.csv"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-230"><a href="#cb2-230" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(wikidata_name, childof_name, realparent) <span class="sc">%&gt;%</span></span>
<span id="cb2-231"><a href="#cb2-231" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(realparent <span class="sc">==</span> <span class="dv">1</span> <span class="sc">|</span></span>
<span id="cb2-232"><a href="#cb2-232" aria-hidden="true" tabindex="-1"></a>                  <span class="fu">is.na</span>(realparent)) <span class="sc">%&gt;%</span></span>
<span id="cb2-233"><a href="#cb2-233" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">distinct</span>() <span class="sc">%&gt;%</span></span>
<span id="cb2-234"><a href="#cb2-234" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(<span class="sc">-</span>realparent) <span class="sc">%&gt;%</span></span>
<span id="cb2-235"><a href="#cb2-235" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">mutate</span>(<span class="at">childof_name =</span> dplyr<span class="sc">::</span><span class="fu">if_else</span>(childof_name <span class="sc">==</span> <span class="st">"NA"</span>, <span class="st">"intervention"</span>, childof_name)) <span class="sc">%&gt;%</span></span>
<span id="cb2-236"><a href="#cb2-236" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">rename</span>(<span class="at">child =</span> wikidata_name,</span>
<span id="cb2-237"><a href="#cb2-237" aria-hidden="true" tabindex="-1"></a>                <span class="at">parent =</span> childof_name) <span class="sc">%&gt;%</span></span>
<span id="cb2-238"><a href="#cb2-238" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(parent, child) <span class="sc">%&gt;%</span></span>
<span id="cb2-239"><a href="#cb2-239" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">mutate_all</span>( <span class="sc">~</span> stringr<span class="sc">::</span><span class="fu">str_replace_all</span>(., <span class="st">" "</span>, <span class="st">"_"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-240"><a href="#cb2-240" aria-hidden="true" tabindex="-1"></a>  <span class="fu">na.omit</span>()</span>
<span id="cb2-241"><a href="#cb2-241" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-242"><a href="#cb2-242" aria-hidden="true" tabindex="-1"></a><span class="co"># Testing</span></span>
<span id="cb2-243"><a href="#cb2-243" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(igraph)</span>
<span id="cb2-244"><a href="#cb2-244" aria-hidden="true" tabindex="-1"></a>tree <span class="ot">&lt;-</span> igraph<span class="sc">::</span><span class="fu">graph_from_edgelist</span>(<span class="fu">as.matrix</span>(dependency))</span>
<span id="cb2-245"><a href="#cb2-245" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-246"><a href="#cb2-246" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(ggraph)</span>
<span id="cb2-247"><a href="#cb2-247" aria-hidden="true" tabindex="-1"></a><span class="fu">ggraph</span>(tree, <span class="at">layout =</span> <span class="st">'tree'</span>) <span class="sc">+</span></span>
<span id="cb2-248"><a href="#cb2-248" aria-hidden="true" tabindex="-1"></a>  <span class="fu">geom_edge_diagonal</span>(<span class="at">edge_width =</span> <span class="fl">0.05</span>,</span>
<span id="cb2-249"><a href="#cb2-249" aria-hidden="true" tabindex="-1"></a>                 <span class="at">color =</span> <span class="st">'steelblue'</span>) <span class="sc">+</span></span>
<span id="cb2-250"><a href="#cb2-250" aria-hidden="true" tabindex="-1"></a>  <span class="fu">geom_node_point</span>(<span class="at">size =</span> <span class="fl">0.05</span>) <span class="sc">+</span></span>
<span id="cb2-251"><a href="#cb2-251" aria-hidden="true" tabindex="-1"></a>  <span class="fu">coord_flip</span>() <span class="sc">+</span></span>
<span id="cb2-252"><a href="#cb2-252" aria-hidden="true" tabindex="-1"></a>  <span class="fu">scale_y_reverse</span>() <span class="sc">+</span></span>
<span id="cb2-253"><a href="#cb2-253" aria-hidden="true" tabindex="-1"></a>  <span class="fu">theme_void</span>()</span>
<span id="cb2-254"><a href="#cb2-254" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-255"><a href="#cb2-255" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="at">height =</span> <span class="dv">10</span>, <span class="fu">paste0</span>(here<span class="sc">::</span><span class="fu">here</span>(), <span class="st">"/paper/figures/"</span>,<span class="st">"fig_dendrogram1.png"</span>))</span>
<span id="cb2-256"><a href="#cb2-256" aria-hidden="true" tabindex="-1"></a><span class="in">```</span></span>
<span id="cb2-257"><a href="#cb2-257" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-258"><a href="#cb2-258" aria-hidden="true" tabindex="-1"></a><span class="fu"># Nested Gulf War</span></span>
<span id="cb2-259"><a href="#cb2-259" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-262"><a href="#cb2-262" aria-hidden="true" tabindex="-1"></a><span class="in">```{r}</span></span>
<span id="cb2-263"><a href="#cb2-263" aria-hidden="true" tabindex="-1"></a><span class="co"># fig height 4, width 6</span></span>
<span id="cb2-264"><a href="#cb2-264" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-265"><a href="#cb2-265" aria-hidden="true" tabindex="-1"></a>dependency <span class="ot">&lt;-</span> <span class="fu">read.csv</span>(<span class="fu">paste0</span>(here<span class="sc">::</span><span class="fu">here</span>(), <span class="st">"/data/raw/"</span>,<span class="st">"03_newdata_childof.csv"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-266"><a href="#cb2-266" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(wikidata_name, childof_name, realparent) <span class="sc">%&gt;%</span></span>
<span id="cb2-267"><a href="#cb2-267" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(realparent <span class="sc">==</span> <span class="dv">1</span> <span class="sc">|</span></span>
<span id="cb2-268"><a href="#cb2-268" aria-hidden="true" tabindex="-1"></a>                  <span class="fu">is.na</span>(realparent)) <span class="sc">%&gt;%</span></span>
<span id="cb2-269"><a href="#cb2-269" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">distinct</span>() <span class="sc">%&gt;%</span></span>
<span id="cb2-270"><a href="#cb2-270" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(<span class="sc">-</span>realparent) <span class="sc">%&gt;%</span></span>
<span id="cb2-271"><a href="#cb2-271" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">mutate</span>(<span class="at">childof_name =</span> dplyr<span class="sc">::</span><span class="fu">if_else</span>(childof_name <span class="sc">==</span> <span class="st">"NA"</span>, <span class="st">"intervention"</span>, childof_name)) <span class="sc">%&gt;%</span></span>
<span id="cb2-272"><a href="#cb2-272" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">rename</span>(<span class="at">child =</span> wikidata_name,</span>
<span id="cb2-273"><a href="#cb2-273" aria-hidden="true" tabindex="-1"></a>                <span class="at">parent =</span> childof_name) <span class="sc">%&gt;%</span></span>
<span id="cb2-274"><a href="#cb2-274" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(parent, child) <span class="sc">%&gt;%</span></span>
<span id="cb2-275"><a href="#cb2-275" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">mutate_all</span>( <span class="sc">~</span> stringr<span class="sc">::</span><span class="fu">str_replace_all</span>(., <span class="st">" "</span>, <span class="st">"_"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-276"><a href="#cb2-276" aria-hidden="true" tabindex="-1"></a>  <span class="fu">na.omit</span>() <span class="sc">%&gt;%</span></span>
<span id="cb2-277"><a href="#cb2-277" aria-hidden="true" tabindex="-1"></a>    dplyr<span class="sc">::</span><span class="fu">filter</span>(parent <span class="sc">%in%</span> <span class="fu">c</span>(<span class="st">"Gulf_War"</span>,</span>
<span id="cb2-278"><a href="#cb2-278" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Gulf_War_air_campaign"</span>,</span>
<span id="cb2-279"><a href="#cb2-279" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Iraqi_no-fly_zones"</span>,</span>
<span id="cb2-280"><a href="#cb2-280" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Liberation_of_Kuwait_campaign"</span>,</span>
<span id="cb2-281"><a href="#cb2-281" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Lead-up_to_the_Iraq_War"</span>,</span>
<span id="cb2-282"><a href="#cb2-282" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Operation_Southern_Watch"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-283"><a href="#cb2-283" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(<span class="sc">!</span>child <span class="sc">%in%</span> <span class="fu">c</span>(<span class="st">"Operation_Desert_Shield"</span>,</span>
<span id="cb2-284"><a href="#cb2-284" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Operation_Instant_Thunder"</span>,</span>
<span id="cb2-285"><a href="#cb2-285" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Operation_Desert_Thunder"</span>,</span>
<span id="cb2-286"><a href="#cb2-286" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Kurdistan_Islamist_Conflict"</span>,</span>
<span id="cb2-287"><a href="#cb2-287" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Defense_of_Saudi_Arabian_country"</span>,</span>
<span id="cb2-288"><a href="#cb2-288" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Battle_of_Bubiyan"</span>,</span>
<span id="cb2-289"><a href="#cb2-289" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Battle_for_Jalibah_Airfield"</span>,</span>
<span id="cb2-290"><a href="#cb2-290" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Battle_of_Al_Busayyah"</span>,</span>
<span id="cb2-291"><a href="#cb2-291" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Battle_of_Medina_Ridge"</span>,</span>
<span id="cb2-292"><a href="#cb2-292" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Battle_of_Phase_Line_Bullet"</span>,</span>
<span id="cb2-293"><a href="#cb2-293" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Battle_of_Rumaila"</span>,</span>
<span id="cb2-294"><a href="#cb2-294" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Iraqi_Kurdish_Civil_War"</span>))</span>
<span id="cb2-295"><a href="#cb2-295" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-296"><a href="#cb2-296" aria-hidden="true" tabindex="-1"></a><span class="co"># Defense of Saudi Arabian country for the period 2 August 1990, through 16 January 1991.</span></span>
<span id="cb2-297"><a href="#cb2-297" aria-hidden="true" tabindex="-1"></a><span class="co"># Liberation and Defense of Kuwait for the period 17 January 1991, through 11 April 1991.</span></span>
<span id="cb2-298"><a href="#cb2-298" aria-hidden="true" tabindex="-1"></a><span class="co"># Southwest Asia Cease-Fire for the period 12 April 1991, through 30 November 1995, including Operation Provide Comfort.</span></span>
<span id="cb2-299"><a href="#cb2-299" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-300"><a href="#cb2-300" aria-hidden="true" tabindex="-1"></a><span class="co"># Phylo tree</span></span>
<span id="cb2-301"><a href="#cb2-301" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(ggtree)</span>
<span id="cb2-302"><a href="#cb2-302" aria-hidden="true" tabindex="-1"></a>tree <span class="ot">&lt;-</span> dependency <span class="sc">%&gt;%</span></span>
<span id="cb2-303"><a href="#cb2-303" aria-hidden="true" tabindex="-1"></a>  treeio<span class="sc">::</span><span class="fu">as.phylo</span>() <span class="sc">%&gt;%</span></span>
<span id="cb2-304"><a href="#cb2-304" aria-hidden="true" tabindex="-1"></a>  ggtree<span class="sc">::</span><span class="fu">ggtree</span>(<span class="at">color =</span> <span class="st">"black"</span>,</span>
<span id="cb2-305"><a href="#cb2-305" aria-hidden="true" tabindex="-1"></a>                 <span class="at">linetype =</span> <span class="dv">1</span>,</span>
<span id="cb2-306"><a href="#cb2-306" aria-hidden="true" tabindex="-1"></a>                 <span class="at">layout =</span> <span class="st">"roundrect"</span>) <span class="sc">+</span></span>
<span id="cb2-307"><a href="#cb2-307" aria-hidden="true" tabindex="-1"></a>  <span class="fu">geom_tiplab</span>(<span class="at">size =</span> <span class="dv">3</span>) <span class="sc">+</span></span>
<span id="cb2-308"><a href="#cb2-308" aria-hidden="true" tabindex="-1"></a>  <span class="fu">geom_nodelab</span>(<span class="at">geom =</span> <span class="st">"label"</span>,</span>
<span id="cb2-309"><a href="#cb2-309" aria-hidden="true" tabindex="-1"></a>               <span class="at">size =</span> <span class="dv">3</span>) <span class="sc">+</span></span>
<span id="cb2-310"><a href="#cb2-310" aria-hidden="true" tabindex="-1"></a>  <span class="fu">xlim</span>(<span class="sc">-</span><span class="fl">0.1</span>, <span class="fl">4.5</span>)</span>
<span id="cb2-311"><a href="#cb2-311" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-312"><a href="#cb2-312" aria-hidden="true" tabindex="-1"></a>tree<span class="sc">$</span>data<span class="sc">$</span>label <span class="ot">&lt;-</span> stringr<span class="sc">::</span><span class="fu">str_replace_all</span>(tree<span class="sc">$</span>data<span class="sc">$</span>label, <span class="st">"_"</span>, <span class="st">" "</span>)</span>
<span id="cb2-313"><a href="#cb2-313" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-314"><a href="#cb2-314" aria-hidden="true" tabindex="-1"></a><span class="co"># Heatmap of the above child nodes</span></span>
<span id="cb2-315"><a href="#cb2-315" aria-hidden="true" tabindex="-1"></a>heat <span class="ot">&lt;-</span> dependency <span class="sc">%&gt;%</span></span>
<span id="cb2-316"><a href="#cb2-316" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(child <span class="sc">%in%</span> <span class="fu">c</span>(<span class="st">"1993_cruise_missile_strikes_on_Iraq"</span>,</span>
<span id="cb2-317"><a href="#cb2-317" aria-hidden="true" tabindex="-1"></a>                             <span class="st">"Amiriyah_shelter_bombing"</span>,</span>
<span id="cb2-318"><a href="#cb2-318" aria-hidden="true" tabindex="-1"></a>                             <span class="st">"Attack_on_Ras_Tanura"</span>,</span>
<span id="cb2-319"><a href="#cb2-319" aria-hidden="true" tabindex="-1"></a>                             <span class="st">"Battle_of_73_Easting"</span>,</span>
<span id="cb2-320"><a href="#cb2-320" aria-hidden="true" tabindex="-1"></a>                             <span class="st">"Battle_of_Ad-Dawrah"</span>,</span>
<span id="cb2-321"><a href="#cb2-321" aria-hidden="true" tabindex="-1"></a>                             <span class="st">"Battle_of_Khafji"</span>,</span>
<span id="cb2-322"><a href="#cb2-322" aria-hidden="true" tabindex="-1"></a>                             <span class="st">"Battle_of_Kuwait_International_Airport"</span>,</span>
<span id="cb2-323"><a href="#cb2-323" aria-hidden="true" tabindex="-1"></a>                             <span class="st">"Battle_of_Norfolk"</span>,</span>
<span id="cb2-324"><a href="#cb2-324" aria-hidden="true" tabindex="-1"></a>                             <span class="st">"Battle_of_Qurah_and_Umm_al_Maradim"</span>,</span>
<span id="cb2-325"><a href="#cb2-325" aria-hidden="true" tabindex="-1"></a>                             <span class="st">"Battle_of_Wadi_Al-Batin"</span>,</span>
<span id="cb2-326"><a href="#cb2-326" aria-hidden="true" tabindex="-1"></a>                             <span class="st">"Bombing_of_Iraq"</span>,</span>
<span id="cb2-327"><a href="#cb2-327" aria-hidden="true" tabindex="-1"></a>                             <span class="st">"Cruise_missile_strikes_on_Iraq"</span>,</span>
<span id="cb2-328"><a href="#cb2-328" aria-hidden="true" tabindex="-1"></a>                             <span class="st">"January_1993_airstrikes_on_Iraq"</span>,</span>
<span id="cb2-329"><a href="#cb2-329" aria-hidden="true" tabindex="-1"></a>                             <span class="st">"Package_Q_Strike"</span>,</span>
<span id="cb2-330"><a href="#cb2-330" aria-hidden="true" tabindex="-1"></a>                             <span class="st">"Operation_Desert_Spring"</span>,</span>
<span id="cb2-331"><a href="#cb2-331" aria-hidden="true" tabindex="-1"></a>                             <span class="st">"Operation_Northern_Watch"</span>,</span>
<span id="cb2-332"><a href="#cb2-332" aria-hidden="true" tabindex="-1"></a>                             <span class="st">"Operation_Provide_Comfort"</span>,</span>
<span id="cb2-333"><a href="#cb2-333" aria-hidden="true" tabindex="-1"></a>                             <span class="st">"Operation_Senior_Surprise"</span>,</span>
<span id="cb2-334"><a href="#cb2-334" aria-hidden="true" tabindex="-1"></a>                             <span class="st">"Operation_Southern_Focus"</span>,</span>
<span id="cb2-335"><a href="#cb2-335" aria-hidden="true" tabindex="-1"></a>                             <span class="st">"Operation_Vigilant_Sentinel"</span>,</span>
<span id="cb2-336"><a href="#cb2-336" aria-hidden="true" tabindex="-1"></a>                             <span class="st">"Operation_Vigilant_Warrior"</span>,</span>
<span id="cb2-337"><a href="#cb2-337" aria-hidden="true" tabindex="-1"></a>                             <span class="st">"Samurra_Air_Battle"</span>))</span>
<span id="cb2-338"><a href="#cb2-338" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-339"><a href="#cb2-339" aria-hidden="true" tabindex="-1"></a>df_interv_heat <span class="ot">&lt;-</span> df_interv <span class="sc">%&gt;%</span></span>
<span id="cb2-340"><a href="#cb2-340" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(wikidata_name, dplyr<span class="sc">::</span><span class="fu">starts_with</span>(<span class="st">"means_"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-341"><a href="#cb2-341" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">mutate_all</span>( <span class="sc">~</span> stringr<span class="sc">::</span><span class="fu">str_replace_all</span>(., <span class="st">" "</span>, <span class="st">"_"</span>))</span>
<span id="cb2-342"><a href="#cb2-342" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-343"><a href="#cb2-343" aria-hidden="true" tabindex="-1"></a>heat <span class="ot">&lt;-</span> dplyr<span class="sc">::</span><span class="fu">left_join</span>(heat, df_interv_heat, <span class="at">by =</span> <span class="fu">c</span>(<span class="st">"child"</span> <span class="ot">=</span> <span class="st">"wikidata_name"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-344"><a href="#cb2-344" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(child, dplyr<span class="sc">::</span><span class="fu">starts_with</span>(<span class="st">"means_"</span>))  <span class="sc">%&gt;%</span></span>
<span id="cb2-345"><a href="#cb2-345" aria-hidden="true" tabindex="-1"></a>  tidyr<span class="sc">::</span><span class="fu">pivot_longer</span>(<span class="at">cols =</span> dplyr<span class="sc">::</span><span class="fu">starts_with</span>(<span class="st">"means_"</span>),</span>
<span id="cb2-346"><a href="#cb2-346" aria-hidden="true" tabindex="-1"></a>                      <span class="at">names_to =</span> <span class="st">"means"</span>,</span>
<span id="cb2-347"><a href="#cb2-347" aria-hidden="true" tabindex="-1"></a>                      <span class="at">values_to =</span> <span class="st">"used"</span>) <span class="sc">%&gt;%</span></span>
<span id="cb2-348"><a href="#cb2-348" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">mutate</span>(<span class="at">means =</span> stringr<span class="sc">::</span><span class="fu">str_remove</span>(means, <span class="st">"means_"</span>),</span>
<span id="cb2-349"><a href="#cb2-349" aria-hidden="true" tabindex="-1"></a>                <span class="at">used =</span> <span class="fu">as.numeric</span>(used))</span>
<span id="cb2-350"><a href="#cb2-350" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-351"><a href="#cb2-351" aria-hidden="true" tabindex="-1"></a>heat <span class="ot">&lt;-</span> heat <span class="sc">%&gt;%</span></span>
<span id="cb2-352"><a href="#cb2-352" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">mutate</span>(<span class="at">child =</span> stringr<span class="sc">::</span><span class="fu">str_replace_all</span>(child, <span class="st">"_"</span>, <span class="st">" "</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-353"><a href="#cb2-353" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">mutate</span>(<span class="at">child =</span> <span class="fu">as.factor</span>(child)) <span class="sc">%&gt;%</span></span>
<span id="cb2-354"><a href="#cb2-354" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">mutate</span>(<span class="at">child =</span> forcats<span class="sc">::</span><span class="fu">fct_relevel</span>(child, </span>
<span id="cb2-355"><a href="#cb2-355" aria-hidden="true" tabindex="-1"></a>                                             <span class="st">"Amiriyah shelter bombing"</span>,</span>
<span id="cb2-356"><a href="#cb2-356" aria-hidden="true" tabindex="-1"></a>                                             <span class="st">"Attack on Ras Tanura"</span>,</span>
<span id="cb2-357"><a href="#cb2-357" aria-hidden="true" tabindex="-1"></a>                                             <span class="st">"Package Q Strike"</span>,</span>
<span id="cb2-358"><a href="#cb2-358" aria-hidden="true" tabindex="-1"></a>                                             <span class="st">"Samurra Air Battle"</span>,</span>
<span id="cb2-359"><a href="#cb2-359" aria-hidden="true" tabindex="-1"></a>                                             <span class="st">"Battle of 73 Easting"</span>,</span>
<span id="cb2-360"><a href="#cb2-360" aria-hidden="true" tabindex="-1"></a>                                             <span class="st">"Battle of Ad-Dawrah"</span>,</span>
<span id="cb2-361"><a href="#cb2-361" aria-hidden="true" tabindex="-1"></a>                                             <span class="st">"Battle of Khafji"</span>,</span>
<span id="cb2-362"><a href="#cb2-362" aria-hidden="true" tabindex="-1"></a>                                             <span class="st">"Battle of Kuwait International Airport"</span>,</span>
<span id="cb2-363"><a href="#cb2-363" aria-hidden="true" tabindex="-1"></a>                                             <span class="st">"Battle of Norfolk"</span>,</span>
<span id="cb2-364"><a href="#cb2-364" aria-hidden="true" tabindex="-1"></a>                                             <span class="st">"Battle of Qurah and Umm al Maradim"</span>,</span>
<span id="cb2-365"><a href="#cb2-365" aria-hidden="true" tabindex="-1"></a>                                             <span class="st">"Battle of Wadi Al-Batin"</span>,</span>
<span id="cb2-366"><a href="#cb2-366" aria-hidden="true" tabindex="-1"></a>                                             <span class="st">"Operation Senior Surprise"</span>,</span>
<span id="cb2-367"><a href="#cb2-367" aria-hidden="true" tabindex="-1"></a>                                             <span class="st">"Cruise missile strikes on Iraq"</span>,</span>
<span id="cb2-368"><a href="#cb2-368" aria-hidden="true" tabindex="-1"></a>                                             <span class="st">"Operation Vigilant Sentinel"</span>,</span>
<span id="cb2-369"><a href="#cb2-369" aria-hidden="true" tabindex="-1"></a>                                             <span class="st">"Operation Desert Spring"</span>,</span>
<span id="cb2-370"><a href="#cb2-370" aria-hidden="true" tabindex="-1"></a>                                             <span class="st">"Operation Northern Watch"</span>,</span>
<span id="cb2-371"><a href="#cb2-371" aria-hidden="true" tabindex="-1"></a>                                             <span class="st">"Operation Provide Comfort"</span>,</span>
<span id="cb2-372"><a href="#cb2-372" aria-hidden="true" tabindex="-1"></a>                                             <span class="st">"1993 cruise missile strikes on Iraq"</span>,</span>
<span id="cb2-373"><a href="#cb2-373" aria-hidden="true" tabindex="-1"></a>                                             <span class="st">"Bombing of Iraq"</span>,</span>
<span id="cb2-374"><a href="#cb2-374" aria-hidden="true" tabindex="-1"></a>                                             <span class="st">"January 1993 airstrikes on Iraq"</span>,</span>
<span id="cb2-375"><a href="#cb2-375" aria-hidden="true" tabindex="-1"></a>                                             <span class="st">"Operation Southern Focus"</span>,</span>
<span id="cb2-376"><a href="#cb2-376" aria-hidden="true" tabindex="-1"></a>                                             <span class="st">"Operation Vigilant Warrior"</span>))</span>
<span id="cb2-377"><a href="#cb2-377" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-378"><a href="#cb2-378" aria-hidden="true" tabindex="-1"></a>hmap <span class="ot">&lt;-</span> ggplot2<span class="sc">::</span><span class="fu">ggplot</span>(heat,</span>
<span id="cb2-379"><a href="#cb2-379" aria-hidden="true" tabindex="-1"></a>                  <span class="fu">aes</span>(<span class="at">y =</span> child, <span class="at">x =</span> means, <span class="at">fill =</span> used)) <span class="sc">+</span></span>
<span id="cb2-380"><a href="#cb2-380" aria-hidden="true" tabindex="-1"></a>  <span class="fu">geom_tile</span>(<span class="at">color =</span> <span class="st">"white"</span>,</span>
<span id="cb2-381"><a href="#cb2-381" aria-hidden="true" tabindex="-1"></a>            <span class="at">lwd =</span> <span class="fl">0.3</span>) <span class="sc">+</span></span>
<span id="cb2-382"><a href="#cb2-382" aria-hidden="true" tabindex="-1"></a>  <span class="fu">scale_fill_gradient</span>(<span class="at">low =</span> <span class="st">"white"</span>, <span class="at">high =</span> <span class="st">"red"</span>) <span class="sc">+</span></span>
<span id="cb2-383"><a href="#cb2-383" aria-hidden="true" tabindex="-1"></a>  <span class="fu">theme</span>(<span class="at">legend.position =</span> <span class="st">"none"</span>,</span>
<span id="cb2-384"><a href="#cb2-384" aria-hidden="true" tabindex="-1"></a>        <span class="at">axis.text.y =</span> <span class="fu">element_blank</span>(),</span>
<span id="cb2-385"><a href="#cb2-385" aria-hidden="true" tabindex="-1"></a>        <span class="at">axis.title.y =</span> <span class="fu">element_blank</span>(),</span>
<span id="cb2-386"><a href="#cb2-386" aria-hidden="true" tabindex="-1"></a>        <span class="at">axis.text.x =</span> <span class="fu">element_text</span>(<span class="at">angle =</span> <span class="dv">90</span>,</span>
<span id="cb2-387"><a href="#cb2-387" aria-hidden="true" tabindex="-1"></a>                                   <span class="at">vjust =</span> <span class="sc">-</span><span class="dv">1</span>),</span>
<span id="cb2-388"><a href="#cb2-388" aria-hidden="true" tabindex="-1"></a>        <span class="at">axis.title.x =</span> <span class="fu">element_blank</span>(),</span>
<span id="cb2-389"><a href="#cb2-389" aria-hidden="true" tabindex="-1"></a>        <span class="at">panel.border =</span> <span class="fu">element_rect</span>(<span class="at">color =</span> <span class="st">"black"</span>, <span class="at">fill =</span> <span class="cn">NA</span>, <span class="at">size =</span> <span class="dv">1</span>)) <span class="sc">+</span></span>
<span id="cb2-390"><a href="#cb2-390" aria-hidden="true" tabindex="-1"></a>  <span class="fu">coord_fixed</span>() <span class="sc">+</span></span>
<span id="cb2-391"><a href="#cb2-391" aria-hidden="true" tabindex="-1"></a>  <span class="fu">scale_x_discrete</span>(<span class="at">position =</span> <span class="st">"top"</span>,</span>
<span id="cb2-392"><a href="#cb2-392" aria-hidden="true" tabindex="-1"></a>                   <span class="at">limits =</span> <span class="fu">c</span>(<span class="st">"drones"</span>,</span>
<span id="cb2-393"><a href="#cb2-393" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"cruisemissiles"</span>,</span>
<span id="cb2-394"><a href="#cb2-394" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"airtoair"</span>,</span>
<span id="cb2-395"><a href="#cb2-395" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"aerialbombing"</span>,</span>
<span id="cb2-396"><a href="#cb2-396" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"closeairsupport"</span>,</span>
<span id="cb2-397"><a href="#cb2-397" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"groundtroops"</span>,</span>
<span id="cb2-398"><a href="#cb2-398" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"paramilitary"</span>),</span>
<span id="cb2-399"><a href="#cb2-399" aria-hidden="true" tabindex="-1"></a>                   <span class="at">labels =</span> <span class="fu">c</span>(<span class="st">"Drones"</span>,</span>
<span id="cb2-400"><a href="#cb2-400" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Cruise Missiles"</span>,</span>
<span id="cb2-401"><a href="#cb2-401" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Air-to-Air"</span>,</span>
<span id="cb2-402"><a href="#cb2-402" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Aerial Bombing"</span>,</span>
<span id="cb2-403"><a href="#cb2-403" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Close Air Support"</span>,</span>
<span id="cb2-404"><a href="#cb2-404" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Ground Troops"</span>,</span>
<span id="cb2-405"><a href="#cb2-405" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Paramilitary"</span>))</span>
<span id="cb2-406"><a href="#cb2-406" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-407"><a href="#cb2-407" aria-hidden="true" tabindex="-1"></a>cowplot<span class="sc">::</span><span class="fu">plot_grid</span>(tree, hmap, <span class="at">align =</span> <span class="st">"h"</span>, <span class="at">rel_widths =</span> <span class="fu">c</span>(<span class="fl">4.7</span>, <span class="dv">1</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-408"><a href="#cb2-408" aria-hidden="true" tabindex="-1"></a>  cowplot<span class="sc">::</span><span class="fu">save_plot</span>(<span class="at">filename =</span> <span class="fu">paste0</span>(here<span class="sc">::</span><span class="fu">here</span>(), <span class="st">"/paper/figures/"</span>,<span class="st">"fig_nested1.png"</span>))</span>
<span id="cb2-409"><a href="#cb2-409" aria-hidden="true" tabindex="-1"></a><span class="in">```</span></span>
<span id="cb2-410"><a href="#cb2-410" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-411"><a href="#cb2-411" aria-hidden="true" tabindex="-1"></a><span class="fu"># Map</span></span>
<span id="cb2-412"><a href="#cb2-412" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-415"><a href="#cb2-415" aria-hidden="true" tabindex="-1"></a><span class="in">```{r}</span></span>
<span id="cb2-416"><a href="#cb2-416" aria-hidden="true" tabindex="-1"></a>df_sf <span class="ot">&lt;-</span> <span class="fu">read.csv</span>(<span class="fu">paste0</span>(here<span class="sc">::</span><span class="fu">here</span>(), <span class="st">"/data/"</span>,<span class="st">"MONSTr.csv"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-417"><a href="#cb2-417" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(<span class="sc">!</span><span class="fu">is.na</span>(lat) <span class="sc">&amp;</span> <span class="sc">!</span><span class="fu">is.na</span>(lon)) <span class="sc">%&gt;%</span></span>
<span id="cb2-418"><a href="#cb2-418" aria-hidden="true" tabindex="-1"></a>  sf<span class="sc">::</span><span class="fu">st_as_sf</span>(<span class="at">coords =</span> <span class="fu">c</span>(<span class="st">"lon"</span>, <span class="st">"lat"</span>))</span>
<span id="cb2-419"><a href="#cb2-419" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-420"><a href="#cb2-420" aria-hidden="true" tabindex="-1"></a><span class="co"># Calculate center for view</span></span>
<span id="cb2-421"><a href="#cb2-421" aria-hidden="true" tabindex="-1"></a>WorldData <span class="ot">&lt;-</span> rworldmap<span class="sc">::</span><span class="fu">getMap</span>(<span class="at">resolution =</span> <span class="st">"high"</span>) <span class="sc">%&gt;%</span></span>
<span id="cb2-422"><a href="#cb2-422" aria-hidden="true" tabindex="-1"></a>  sf<span class="sc">::</span><span class="fu">st_as_sf</span>()</span>
<span id="cb2-423"><a href="#cb2-423" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-424"><a href="#cb2-424" aria-hidden="true" tabindex="-1"></a>theme_map <span class="ot">&lt;-</span> <span class="cf">function</span>(<span class="at">base_size =</span> <span class="dv">9</span>, <span class="at">base_family =</span> <span class="st">""</span>) {</span>
<span id="cb2-425"><a href="#cb2-425" aria-hidden="true" tabindex="-1"></a>  <span class="fu">theme_bw</span>(<span class="at">base_size =</span> base_size, <span class="at">base_family =</span> base_family) <span class="sc">%+replace%</span></span>
<span id="cb2-426"><a href="#cb2-426" aria-hidden="true" tabindex="-1"></a>    <span class="fu">theme</span>(<span class="at">axis.line =</span> <span class="fu">element_blank</span>(),</span>
<span id="cb2-427"><a href="#cb2-427" aria-hidden="true" tabindex="-1"></a>          <span class="at">axis.text =</span> <span class="fu">element_blank</span>(),</span>
<span id="cb2-428"><a href="#cb2-428" aria-hidden="true" tabindex="-1"></a>          <span class="at">axis.ticks =</span> <span class="fu">element_blank</span>(),</span>
<span id="cb2-429"><a href="#cb2-429" aria-hidden="true" tabindex="-1"></a>          <span class="at">axis.title =</span> <span class="fu">element_blank</span>(),</span>
<span id="cb2-430"><a href="#cb2-430" aria-hidden="true" tabindex="-1"></a>          <span class="at">panel.background =</span> <span class="fu">element_blank</span>(),</span>
<span id="cb2-431"><a href="#cb2-431" aria-hidden="true" tabindex="-1"></a>          <span class="at">panel.border =</span> <span class="fu">element_blank</span>(),</span>
<span id="cb2-432"><a href="#cb2-432" aria-hidden="true" tabindex="-1"></a>          <span class="at">panel.grid =</span> <span class="fu">element_blank</span>(),</span>
<span id="cb2-433"><a href="#cb2-433" aria-hidden="true" tabindex="-1"></a>          <span class="at">panel.spacing =</span> <span class="fu">unit</span>(<span class="dv">0</span>, <span class="st">"lines"</span>),</span>
<span id="cb2-434"><a href="#cb2-434" aria-hidden="true" tabindex="-1"></a>          <span class="at">plot.background =</span> <span class="fu">element_blank</span>(),</span>
<span id="cb2-435"><a href="#cb2-435" aria-hidden="true" tabindex="-1"></a>          <span class="at">legend.justification =</span> <span class="fu">c</span>(<span class="dv">0</span>, <span class="dv">0</span>)<span class="co">#,</span></span>
<span id="cb2-436"><a href="#cb2-436" aria-hidden="true" tabindex="-1"></a>          <span class="co">#legend.position = c(1,1)</span></span>
<span id="cb2-437"><a href="#cb2-437" aria-hidden="true" tabindex="-1"></a>    )</span>
<span id="cb2-438"><a href="#cb2-438" aria-hidden="true" tabindex="-1"></a>  }</span>
<span id="cb2-439"><a href="#cb2-439" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-440"><a href="#cb2-440" aria-hidden="true" tabindex="-1"></a>df_map <span class="ot">&lt;-</span> df_interv <span class="sc">%&gt;%</span></span>
<span id="cb2-441"><a href="#cb2-441" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(<span class="sc">!</span><span class="fu">is.na</span>(urban_binary)) <span class="sc">%&gt;%</span></span>
<span id="cb2-442"><a href="#cb2-442" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">mutate</span>(<span class="at">means_ground =</span> <span class="fu">ifelse</span>(means_groundtroops <span class="sc">==</span> <span class="dv">1</span> <span class="sc">|</span></span>
<span id="cb2-443"><a href="#cb2-443" aria-hidden="true" tabindex="-1"></a>                                        means_paramilitary <span class="sc">==</span> <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">0</span>),</span>
<span id="cb2-444"><a href="#cb2-444" aria-hidden="true" tabindex="-1"></a>                <span class="at">means_air =</span> <span class="fu">ifelse</span>(means_aerialbombing <span class="sc">==</span> <span class="dv">1</span> <span class="sc">|</span></span>
<span id="cb2-445"><a href="#cb2-445" aria-hidden="true" tabindex="-1"></a>                                     means_airtoair <span class="sc">==</span> <span class="dv">1</span> <span class="sc">|</span></span>
<span id="cb2-446"><a href="#cb2-446" aria-hidden="true" tabindex="-1"></a>                                     means_drones <span class="sc">==</span> <span class="dv">1</span> <span class="sc">|</span></span>
<span id="cb2-447"><a href="#cb2-447" aria-hidden="true" tabindex="-1"></a>                                     means_closeairsupport <span class="sc">==</span> <span class="dv">1</span> <span class="sc">|</span></span>
<span id="cb2-448"><a href="#cb2-448" aria-hidden="true" tabindex="-1"></a>                                     means_cruisemissiles <span class="sc">==</span> <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">0</span>),</span>
<span id="cb2-449"><a href="#cb2-449" aria-hidden="true" tabindex="-1"></a>                <span class="at">means_factor =</span> <span class="fu">ifelse</span>(means_ground <span class="sc">==</span> <span class="dv">1</span> <span class="sc">&amp;</span></span>
<span id="cb2-450"><a href="#cb2-450" aria-hidden="true" tabindex="-1"></a>                                        means_air <span class="sc">==</span> <span class="dv">0</span>, <span class="st">"Ground"</span>, <span class="cn">NA</span>),</span>
<span id="cb2-451"><a href="#cb2-451" aria-hidden="true" tabindex="-1"></a>                <span class="at">means_factor =</span> <span class="fu">ifelse</span>(means_air <span class="sc">==</span> <span class="dv">1</span> <span class="sc">&amp;</span></span>
<span id="cb2-452"><a href="#cb2-452" aria-hidden="true" tabindex="-1"></a>                                        means_ground <span class="sc">==</span> <span class="dv">0</span>, <span class="st">"Air"</span>, means_factor),</span>
<span id="cb2-453"><a href="#cb2-453" aria-hidden="true" tabindex="-1"></a>                <span class="at">means_factor =</span> <span class="fu">ifelse</span>(means_ground <span class="sc">==</span> <span class="dv">1</span> <span class="sc">&amp;</span></span>
<span id="cb2-454"><a href="#cb2-454" aria-hidden="true" tabindex="-1"></a>                                        means_air <span class="sc">==</span> <span class="dv">1</span>, <span class="st">"Mixed"</span>, means_factor),</span>
<span id="cb2-455"><a href="#cb2-455" aria-hidden="true" tabindex="-1"></a>                <span class="at">urban_binary =</span> <span class="fu">ifelse</span>(urban_binary <span class="sc">==</span> <span class="dv">1</span>, <span class="st">"Urban Target"</span>, <span class="st">"Non-urban Target"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-456"><a href="#cb2-456" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(<span class="sc">!</span><span class="fu">is.na</span>(means_factor))</span>
<span id="cb2-457"><a href="#cb2-457" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-458"><a href="#cb2-458" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(<span class="at">data =</span> WorldData) <span class="sc">+</span></span>
<span id="cb2-459"><a href="#cb2-459" aria-hidden="true" tabindex="-1"></a>  <span class="fu">geom_sf</span>(<span class="at">fill =</span> <span class="st">"antiquewhite1"</span>,</span>
<span id="cb2-460"><a href="#cb2-460" aria-hidden="true" tabindex="-1"></a>          <span class="at">size =</span> <span class="fl">0.25</span>) <span class="sc">+</span></span>
<span id="cb2-461"><a href="#cb2-461" aria-hidden="true" tabindex="-1"></a>  <span class="fu">coord_sf</span>(<span class="at">xlim =</span> <span class="fu">c</span>(<span class="dv">35</span>, <span class="dv">75</span>), <span class="at">ylim =</span> <span class="fu">c</span>(<span class="dv">28</span>, <span class="dv">39</span>), <span class="at">expand =</span> <span class="cn">FALSE</span>) <span class="sc">+</span></span>
<span id="cb2-462"><a href="#cb2-462" aria-hidden="true" tabindex="-1"></a>  <span class="fu">geom_sf_text</span>(<span class="at">data =</span> WorldData[WorldData<span class="sc">$</span>SOVEREIGNT <span class="sc">%in%</span> <span class="fu">c</span>(<span class="st">"Afghanistan"</span>, <span class="st">"Pakistan"</span>, <span class="st">"Iraq"</span>, <span class="st">"Syria"</span>, <span class="st">"Kuwait"</span>), ],</span>
<span id="cb2-463"><a href="#cb2-463" aria-hidden="true" tabindex="-1"></a>               <span class="fu">aes</span>(<span class="at">label =</span> NAME),</span>
<span id="cb2-464"><a href="#cb2-464" aria-hidden="true" tabindex="-1"></a>               <span class="at">size =</span> <span class="fl">2.5</span>) <span class="sc">+</span></span>
<span id="cb2-465"><a href="#cb2-465" aria-hidden="true" tabindex="-1"></a>  <span class="fu">geom_point</span>(<span class="at">data =</span> df_map,</span>
<span id="cb2-466"><a href="#cb2-466" aria-hidden="true" tabindex="-1"></a>             <span class="fu">aes</span>(<span class="at">x =</span> lon, <span class="at">y =</span> lat,</span>
<span id="cb2-467"><a href="#cb2-467" aria-hidden="true" tabindex="-1"></a>                 <span class="at">color =</span> means_factor),</span>
<span id="cb2-468"><a href="#cb2-468" aria-hidden="true" tabindex="-1"></a>             <span class="at">size =</span> <span class="fl">0.8</span>) <span class="sc">+</span></span>
<span id="cb2-469"><a href="#cb2-469" aria-hidden="true" tabindex="-1"></a>  <span class="fu">facet_wrap</span>(<span class="sc">~</span> urban_binary,</span>
<span id="cb2-470"><a href="#cb2-470" aria-hidden="true" tabindex="-1"></a>             <span class="at">ncol =</span> <span class="dv">1</span>) <span class="sc">+</span></span>
<span id="cb2-471"><a href="#cb2-471" aria-hidden="true" tabindex="-1"></a>  <span class="fu">scale_color_manual</span>(<span class="at">values =</span> <span class="fu">c</span>(<span class="st">"#7570b3"</span>, <span class="st">"#1b9e77"</span>, <span class="st">"#d95f02"</span>)) <span class="sc">+</span></span>
<span id="cb2-472"><a href="#cb2-472" aria-hidden="true" tabindex="-1"></a>  <span class="fu">xlab</span>(<span class="st">""</span>) <span class="sc">+</span> <span class="fu">ylab</span>(<span class="st">""</span>) <span class="sc">+</span> <span class="fu">labs</span>(<span class="at">color =</span> <span class="st">"Military Means"</span>) <span class="sc">+</span></span>
<span id="cb2-473"><a href="#cb2-473" aria-hidden="true" tabindex="-1"></a>  <span class="fu">theme</span>(<span class="at">panel.grid.major =</span> <span class="fu">element_line</span>(<span class="at">color =</span> <span class="fu">gray</span>(.<span class="dv">5</span>),</span>
<span id="cb2-474"><a href="#cb2-474" aria-hidden="true" tabindex="-1"></a>                                        <span class="at">linetype =</span> <span class="st">"dashed"</span>, <span class="at">size =</span> <span class="fl">0.25</span>),</span>
<span id="cb2-475"><a href="#cb2-475" aria-hidden="true" tabindex="-1"></a>        <span class="at">panel.background =</span> <span class="fu">element_rect</span>(<span class="at">fill =</span> <span class="st">"aliceblue"</span>),</span>
<span id="cb2-476"><a href="#cb2-476" aria-hidden="true" tabindex="-1"></a>        <span class="at">legend.position =</span> <span class="st">"bottom"</span>,</span>
<span id="cb2-477"><a href="#cb2-477" aria-hidden="true" tabindex="-1"></a>        <span class="at">axis.text =</span> <span class="fu">element_text</span>(<span class="at">size =</span> <span class="dv">5</span>),</span>
<span id="cb2-478"><a href="#cb2-478" aria-hidden="true" tabindex="-1"></a>        <span class="at">strip.background =</span> <span class="fu">element_rect</span>(<span class="at">fill =</span> <span class="st">"white"</span>),</span>
<span id="cb2-479"><a href="#cb2-479" aria-hidden="true" tabindex="-1"></a>        <span class="at">strip.text =</span> <span class="fu">element_text</span>(<span class="at">hjust =</span> <span class="dv">0</span>),</span>
<span id="cb2-480"><a href="#cb2-480" aria-hidden="true" tabindex="-1"></a>        <span class="at">plot.margin =</span> <span class="fu">margin</span>(<span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="st">"cm"</span>)) <span class="sc">+</span></span>
<span id="cb2-481"><a href="#cb2-481" aria-hidden="true" tabindex="-1"></a>  <span class="fu">guides</span>(<span class="at">color =</span> <span class="fu">guide_legend</span>(<span class="at">override.aes =</span> <span class="fu">list</span>(<span class="at">size =</span> <span class="dv">4</span>)))</span>
<span id="cb2-482"><a href="#cb2-482" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-483"><a href="#cb2-483" aria-hidden="true" tabindex="-1"></a><span class="fu">ggsave</span>(<span class="at">height =</span> <span class="dv">5</span>, <span class="at">width =</span> <span class="dv">6</span>, <span class="fu">paste0</span>(here<span class="sc">::</span><span class="fu">here</span>(), <span class="st">"/paper/figures/"</span>,<span class="st">"fig_map1.png"</span>))</span>
<span id="cb2-484"><a href="#cb2-484" aria-hidden="true" tabindex="-1"></a><span class="in">```</span></span>
<span id="cb2-485"><a href="#cb2-485" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-486"><a href="#cb2-486" aria-hidden="true" tabindex="-1"></a><span class="fu"># Network plot</span></span>
<span id="cb2-487"><a href="#cb2-487" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-490"><a href="#cb2-490" aria-hidden="true" tabindex="-1"></a><span class="in">```{r}</span></span>
<span id="cb2-491"><a href="#cb2-491" aria-hidden="true" tabindex="-1"></a><span class="co"># load</span></span>
<span id="cb2-492"><a href="#cb2-492" aria-hidden="true" tabindex="-1"></a>counts <span class="ot">&lt;-</span> <span class="fu">read.csv</span>(<span class="fu">paste0</span>(here<span class="sc">::</span><span class="fu">here</span>(), <span class="st">"/data/raw/"</span>,<span class="st">"02a_newdata_dbpedia.csv"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-493"><a href="#cb2-493" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(wikidata_name, wikidata_id, belligerent_sideA) <span class="sc">%&gt;%</span></span>
<span id="cb2-494"><a href="#cb2-494" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">mutate</span>(<span class="at">belligerent_sideA =</span> stringi<span class="sc">::</span><span class="fu">stri_replace_all_fixed</span>(belligerent_sideA, <span class="st">"("</span>, <span class="st">";"</span>),</span>
<span id="cb2-495"><a href="#cb2-495" aria-hidden="true" tabindex="-1"></a>                <span class="at">belligerent_sideA =</span> stringi<span class="sc">::</span><span class="fu">stri_replace_all_fixed</span>(belligerent_sideA, <span class="st">")"</span>, <span class="st">""</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-496"><a href="#cb2-496" aria-hidden="true" tabindex="-1"></a>  tidyr<span class="sc">::</span><span class="fu">separate_longer_delim</span>(<span class="at">cols =</span> belligerent_sideA, <span class="at">delim =</span> <span class="st">";"</span>) <span class="sc">%&gt;%</span></span>
<span id="cb2-497"><a href="#cb2-497" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">mutate</span>(<span class="at">belligerent_sideA =</span> <span class="fu">trimws</span>(belligerent_sideA))</span>
<span id="cb2-498"><a href="#cb2-498" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-499"><a href="#cb2-499" aria-hidden="true" tabindex="-1"></a>parents <span class="ot">&lt;-</span> <span class="fu">read.csv</span>(<span class="fu">paste0</span>(here<span class="sc">::</span><span class="fu">here</span>(), <span class="st">"/data/"</span>,<span class="st">"MONSTr.csv"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-500"><a href="#cb2-500" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(wikidata_id, parent_id, parent_name)</span>
<span id="cb2-501"><a href="#cb2-501" aria-hidden="true" tabindex="-1"></a><span class="in">```</span></span>
<span id="cb2-502"><a href="#cb2-502" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-503"><a href="#cb2-503" aria-hidden="true" tabindex="-1"></a><span class="fu">## Gulf War</span></span>
<span id="cb2-504"><a href="#cb2-504" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-507"><a href="#cb2-507" aria-hidden="true" tabindex="-1"></a><span class="in">```{r}</span></span>
<span id="cb2-508"><a href="#cb2-508" aria-hidden="true" tabindex="-1"></a><span class="do">## New df of node attributes</span></span>
<span id="cb2-509"><a href="#cb2-509" aria-hidden="true" tabindex="-1"></a>nodes <span class="ot">&lt;-</span> dplyr<span class="sc">::</span><span class="fu">left_join</span>(counts, parents) <span class="sc">%&gt;%</span></span>
<span id="cb2-510"><a href="#cb2-510" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(parent_name <span class="sc">==</span> <span class="st">"Gulf War"</span>) <span class="sc">%&gt;%</span></span>
<span id="cb2-511"><a href="#cb2-511" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(wikidata_name, belligerent_sideA) <span class="sc">%&gt;%</span></span>
<span id="cb2-512"><a href="#cb2-512" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">count</span>(belligerent_sideA)</span>
<span id="cb2-513"><a href="#cb2-513" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-514"><a href="#cb2-514" aria-hidden="true" tabindex="-1"></a>qcodes <span class="ot">&lt;-</span> <span class="fu">read.csv</span>(<span class="fu">paste0</span>(here<span class="sc">::</span><span class="fu">here</span>(), <span class="st">"/data/aux/"</span>,<span class="st">"belligerent_list.csv"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-515"><a href="#cb2-515" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(<span class="fu">is.na</span>(ccode_wrong)) <span class="sc">%&gt;%</span></span>
<span id="cb2-516"><a href="#cb2-516" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(belligerent, ccode, cname, Qcode) <span class="sc">%&gt;%</span></span>
<span id="cb2-517"><a href="#cb2-517" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">rename</span>(<span class="at">belligerent2 =</span> belligerent,</span>
<span id="cb2-518"><a href="#cb2-518" aria-hidden="true" tabindex="-1"></a>                <span class="at">ccode2 =</span> ccode,</span>
<span id="cb2-519"><a href="#cb2-519" aria-hidden="true" tabindex="-1"></a>                <span class="at">cname2 =</span> cname,</span>
<span id="cb2-520"><a href="#cb2-520" aria-hidden="true" tabindex="-1"></a>                <span class="at">qcode2 =</span> Qcode)</span>
<span id="cb2-521"><a href="#cb2-521" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-522"><a href="#cb2-522" aria-hidden="true" tabindex="-1"></a>nodes <span class="ot">&lt;-</span> dplyr<span class="sc">::</span><span class="fu">left_join</span>(nodes, qcodes,</span>
<span id="cb2-523"><a href="#cb2-523" aria-hidden="true" tabindex="-1"></a>                          <span class="at">by =</span> <span class="fu">c</span>(<span class="st">"belligerent_sideA"</span> <span class="ot">=</span> <span class="st">"belligerent2"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-524"><a href="#cb2-524" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">mutate</span>(<span class="at">sideA_nonstate =</span> dplyr<span class="sc">::</span><span class="fu">if_else</span>(<span class="fu">is.na</span>(ccode2), <span class="dv">1</span>, <span class="dv">0</span>),</span>
<span id="cb2-525"><a href="#cb2-525" aria-hidden="true" tabindex="-1"></a>                <span class="at">label =</span> dplyr<span class="sc">::</span><span class="fu">if_else</span>(<span class="fu">is.na</span>(cname2), belligerent_sideA, cname2)) <span class="sc">%&gt;%</span></span>
<span id="cb2-526"><a href="#cb2-526" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(label, belligerent_sideA, n, sideA_nonstate) <span class="sc">%&gt;%</span></span>
<span id="cb2-527"><a href="#cb2-527" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(<span class="sc">!</span>label <span class="sc">%in%</span> <span class="fu">c</span>(<span class="st">"US-led coalition"</span>))</span>
<span id="cb2-528"><a href="#cb2-528" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-529"><a href="#cb2-529" aria-hidden="true" tabindex="-1"></a><span class="do">## Prep adjacency matrix</span></span>
<span id="cb2-530"><a href="#cb2-530" aria-hidden="true" tabindex="-1"></a>actors <span class="ot">&lt;-</span> dplyr<span class="sc">::</span><span class="fu">left_join</span>(counts, parents) <span class="sc">%&gt;%</span></span>
<span id="cb2-531"><a href="#cb2-531" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(parent_name <span class="sc">==</span> <span class="st">"Gulf War"</span>) <span class="sc">%&gt;%</span></span>
<span id="cb2-532"><a href="#cb2-532" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(wikidata_name, wikidata_id, belligerent_sideA) <span class="sc">%&gt;%</span></span>
<span id="cb2-533"><a href="#cb2-533" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">distinct</span>()</span>
<span id="cb2-534"><a href="#cb2-534" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-535"><a href="#cb2-535" aria-hidden="true" tabindex="-1"></a>net_actor <span class="ot">&lt;-</span> dplyr<span class="sc">::</span><span class="fu">left_join</span>(actors, nodes) <span class="sc">%&gt;%</span></span>
<span id="cb2-536"><a href="#cb2-536" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(wikidata_name, label) <span class="sc">%&gt;%</span></span>
<span id="cb2-537"><a href="#cb2-537" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(<span class="sc">!</span>label <span class="sc">%in%</span> <span class="fu">c</span>(<span class="st">"US-led coalition"</span>),</span>
<span id="cb2-538"><a href="#cb2-538" aria-hidden="true" tabindex="-1"></a>                <span class="sc">!</span><span class="fu">is.na</span>(label))</span>
<span id="cb2-539"><a href="#cb2-539" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-540"><a href="#cb2-540" aria-hidden="true" tabindex="-1"></a><span class="do">## Prep network</span></span>
<span id="cb2-541"><a href="#cb2-541" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(igraph)</span>
<span id="cb2-542"><a href="#cb2-542" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-543"><a href="#cb2-543" aria-hidden="true" tabindex="-1"></a>network_gulf <span class="ot">&lt;-</span> <span class="fu">as.matrix</span>(reshape2<span class="sc">::</span><span class="fu">dcast</span>(wikidata_name <span class="sc">~</span> label, <span class="at">data =</span> net_actor, length)[,<span class="sc">-</span><span class="dv">1</span>]<span class="sc">&gt;</span><span class="dv">0</span> )</span>
<span id="cb2-544"><a href="#cb2-544" aria-hidden="true" tabindex="-1"></a>network_gulf <span class="ot">&lt;-</span> <span class="fu">t</span>(network_gulf) <span class="sc">%*%</span> network_gulf</span>
<span id="cb2-545"><a href="#cb2-545" aria-hidden="true" tabindex="-1"></a>network_gulf <span class="ot">&lt;-</span> igraph<span class="sc">::</span><span class="fu">graph_from_adjacency_matrix</span>(network_gulf,</span>
<span id="cb2-546"><a href="#cb2-546" aria-hidden="true" tabindex="-1"></a>                                               <span class="at">mode =</span> <span class="st">"undirected"</span>,</span>
<span id="cb2-547"><a href="#cb2-547" aria-hidden="true" tabindex="-1"></a>                                               <span class="at">weighted =</span> <span class="cn">TRUE</span>,</span>
<span id="cb2-548"><a href="#cb2-548" aria-hidden="true" tabindex="-1"></a>                                               <span class="at">diag =</span> <span class="cn">FALSE</span>)</span>
<span id="cb2-549"><a href="#cb2-549" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-550"><a href="#cb2-550" aria-hidden="true" tabindex="-1"></a><span class="do">## Set node colors for state vs non-state</span></span>
<span id="cb2-551"><a href="#cb2-551" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(RColorBrewer)</span>
<span id="cb2-552"><a href="#cb2-552" aria-hidden="true" tabindex="-1"></a>colrs  <span class="ot">&lt;-</span> RColorBrewer<span class="sc">::</span><span class="fu">brewer.pal</span>(<span class="dv">3</span>, <span class="st">"Dark2"</span>) </span>
<span id="cb2-553"><a href="#cb2-553" aria-hidden="true" tabindex="-1"></a>network_gulf <span class="ot">&lt;-</span> <span class="fu">set_vertex_attr</span>(network_gulf, <span class="st">"type"</span>, nodes<span class="sc">$</span>label, nodes<span class="sc">$</span>sideA_nonstate)</span>
<span id="cb2-554"><a href="#cb2-554" aria-hidden="true" tabindex="-1"></a><span class="fu">V</span>(network_gulf)[<span class="st">"United States"</span>]<span class="sc">$</span>type <span class="ot">&lt;-</span> <span class="st">"center"</span></span>
<span id="cb2-555"><a href="#cb2-555" aria-hidden="true" tabindex="-1"></a>my_color_gulf <span class="ot">&lt;-</span> colrs[<span class="fu">as.numeric</span>(<span class="fu">as.factor</span>(<span class="fu">V</span>(network_gulf)<span class="sc">$</span>type))]</span>
<span id="cb2-556"><a href="#cb2-556" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-557"><a href="#cb2-557" aria-hidden="true" tabindex="-1"></a>deg <span class="ot">&lt;-</span> <span class="fu">degree</span>(network_gulf, <span class="at">mode =</span> <span class="st">"all"</span>)</span>
<span id="cb2-558"><a href="#cb2-558" aria-hidden="true" tabindex="-1"></a><span class="fu">E</span>(network_gulf)<span class="sc">$</span>width <span class="ot">&lt;-</span> <span class="fu">E</span>(network_gulf)<span class="sc">$</span>weight</span>
<span id="cb2-559"><a href="#cb2-559" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-560"><a href="#cb2-560" aria-hidden="true" tabindex="-1"></a><span class="do">## Visualize network</span></span>
<span id="cb2-561"><a href="#cb2-561" aria-hidden="true" tabindex="-1"></a>l <span class="ot">&lt;-</span> <span class="fu">layout_with_graphopt</span>(network_gulf,</span>
<span id="cb2-562"><a href="#cb2-562" aria-hidden="true" tabindex="-1"></a>                          <span class="at">charge =</span> <span class="dv">5</span>)</span>
<span id="cb2-563"><a href="#cb2-563" aria-hidden="true" tabindex="-1"></a><span class="in">```</span></span>
<span id="cb2-564"><a href="#cb2-564" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-565"><a href="#cb2-565" aria-hidden="true" tabindex="-1"></a><span class="fu">## Afghanistan war</span></span>
<span id="cb2-566"><a href="#cb2-566" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-569"><a href="#cb2-569" aria-hidden="true" tabindex="-1"></a><span class="in">```{r}</span></span>
<span id="cb2-570"><a href="#cb2-570" aria-hidden="true" tabindex="-1"></a><span class="do">## New df of node attributes</span></span>
<span id="cb2-571"><a href="#cb2-571" aria-hidden="true" tabindex="-1"></a>nodes <span class="ot">&lt;-</span> dplyr<span class="sc">::</span><span class="fu">left_join</span>(counts, parents) <span class="sc">%&gt;%</span></span>
<span id="cb2-572"><a href="#cb2-572" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(parent_name <span class="sc">==</span> <span class="st">"War in Afghanistan"</span>) <span class="sc">%&gt;%</span></span>
<span id="cb2-573"><a href="#cb2-573" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(wikidata_name, belligerent_sideA) <span class="sc">%&gt;%</span></span>
<span id="cb2-574"><a href="#cb2-574" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">count</span>(belligerent_sideA)</span>
<span id="cb2-575"><a href="#cb2-575" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-576"><a href="#cb2-576" aria-hidden="true" tabindex="-1"></a>qcodes <span class="ot">&lt;-</span> <span class="fu">read.csv</span>(<span class="fu">paste0</span>(here<span class="sc">::</span><span class="fu">here</span>(), <span class="st">"/data/aux/"</span>,<span class="st">"belligerent_list.csv"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-577"><a href="#cb2-577" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(<span class="fu">is.na</span>(ccode_wrong)) <span class="sc">%&gt;%</span></span>
<span id="cb2-578"><a href="#cb2-578" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(belligerent, ccode, cname, Qcode) <span class="sc">%&gt;%</span></span>
<span id="cb2-579"><a href="#cb2-579" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">rename</span>(<span class="at">belligerent2 =</span> belligerent,</span>
<span id="cb2-580"><a href="#cb2-580" aria-hidden="true" tabindex="-1"></a>                <span class="at">ccode2 =</span> ccode,</span>
<span id="cb2-581"><a href="#cb2-581" aria-hidden="true" tabindex="-1"></a>                <span class="at">cname2 =</span> cname,</span>
<span id="cb2-582"><a href="#cb2-582" aria-hidden="true" tabindex="-1"></a>                <span class="at">qcode2 =</span> Qcode)</span>
<span id="cb2-583"><a href="#cb2-583" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-584"><a href="#cb2-584" aria-hidden="true" tabindex="-1"></a>nodes <span class="ot">&lt;-</span> dplyr<span class="sc">::</span><span class="fu">left_join</span>(nodes, qcodes,</span>
<span id="cb2-585"><a href="#cb2-585" aria-hidden="true" tabindex="-1"></a>                          <span class="at">by =</span> <span class="fu">c</span>(<span class="st">"belligerent_sideA"</span> <span class="ot">=</span> <span class="st">"belligerent2"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-586"><a href="#cb2-586" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">mutate</span>(<span class="at">sideA_nonstate =</span> dplyr<span class="sc">::</span><span class="fu">if_else</span>(<span class="fu">is.na</span>(ccode2), <span class="dv">1</span>, <span class="dv">0</span>),</span>
<span id="cb2-587"><a href="#cb2-587" aria-hidden="true" tabindex="-1"></a>                <span class="at">label =</span> dplyr<span class="sc">::</span><span class="fu">if_else</span>(<span class="fu">is.na</span>(ccode2), belligerent_sideA, cname2)) <span class="sc">%&gt;%</span></span>
<span id="cb2-588"><a href="#cb2-588" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(label, belligerent_sideA, n, sideA_nonstate) <span class="sc">%&gt;%</span></span>
<span id="cb2-589"><a href="#cb2-589" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(<span class="sc">!</span>label <span class="sc">%in%</span> <span class="fu">c</span>(<span class="st">"Coalition forces"</span>,</span>
<span id="cb2-590"><a href="#cb2-590" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"International Security Assistance Force"</span>,</span>
<span id="cb2-591"><a href="#cb2-591" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"ISAF"</span>,</span>
<span id="cb2-592"><a href="#cb2-592" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"NATO"</span>,</span>
<span id="cb2-593"><a href="#cb2-593" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Resolute Support Mission"</span>,</span>
<span id="cb2-594"><a href="#cb2-594" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"loyal Afghan fighters"</span>))</span>
<span id="cb2-595"><a href="#cb2-595" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-596"><a href="#cb2-596" aria-hidden="true" tabindex="-1"></a><span class="do">## Prep adjacency matrix</span></span>
<span id="cb2-597"><a href="#cb2-597" aria-hidden="true" tabindex="-1"></a>actors <span class="ot">&lt;-</span> dplyr<span class="sc">::</span><span class="fu">left_join</span>(counts, parents) <span class="sc">%&gt;%</span></span>
<span id="cb2-598"><a href="#cb2-598" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(parent_name <span class="sc">==</span> <span class="st">"War in Afghanistan"</span>) <span class="sc">%&gt;%</span></span>
<span id="cb2-599"><a href="#cb2-599" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(wikidata_name, wikidata_id, belligerent_sideA) <span class="sc">%&gt;%</span></span>
<span id="cb2-600"><a href="#cb2-600" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">distinct</span>()</span>
<span id="cb2-601"><a href="#cb2-601" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-602"><a href="#cb2-602" aria-hidden="true" tabindex="-1"></a>net_actor <span class="ot">&lt;-</span> dplyr<span class="sc">::</span><span class="fu">left_join</span>(actors, nodes) <span class="sc">%&gt;%</span></span>
<span id="cb2-603"><a href="#cb2-603" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(wikidata_name, label) <span class="sc">%&gt;%</span></span>
<span id="cb2-604"><a href="#cb2-604" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(<span class="sc">!</span>label <span class="sc">%in%</span> <span class="fu">c</span>(<span class="st">"Coalition forces"</span>,</span>
<span id="cb2-605"><a href="#cb2-605" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"International Security Assistance Force"</span>,</span>
<span id="cb2-606"><a href="#cb2-606" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"ISAF"</span>,</span>
<span id="cb2-607"><a href="#cb2-607" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"NATO"</span>,</span>
<span id="cb2-608"><a href="#cb2-608" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Resolute Support Mission"</span>),</span>
<span id="cb2-609"><a href="#cb2-609" aria-hidden="true" tabindex="-1"></a>                <span class="sc">!</span><span class="fu">is.na</span>(label))</span>
<span id="cb2-610"><a href="#cb2-610" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-611"><a href="#cb2-611" aria-hidden="true" tabindex="-1"></a><span class="do">## Prep network</span></span>
<span id="cb2-612"><a href="#cb2-612" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(igraph)</span>
<span id="cb2-613"><a href="#cb2-613" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-614"><a href="#cb2-614" aria-hidden="true" tabindex="-1"></a>network_isaf <span class="ot">&lt;-</span> <span class="fu">as.matrix</span>(reshape2<span class="sc">::</span><span class="fu">dcast</span>(wikidata_name <span class="sc">~</span> label, <span class="at">data =</span> net_actor, length)[,<span class="sc">-</span><span class="dv">1</span>]<span class="sc">&gt;</span><span class="dv">0</span> )</span>
<span id="cb2-615"><a href="#cb2-615" aria-hidden="true" tabindex="-1"></a>network_isaf <span class="ot">&lt;-</span> <span class="fu">t</span>(network_isaf) <span class="sc">%*%</span> network_isaf</span>
<span id="cb2-616"><a href="#cb2-616" aria-hidden="true" tabindex="-1"></a>network_isaf <span class="ot">&lt;-</span> igraph<span class="sc">::</span><span class="fu">graph_from_adjacency_matrix</span>(network_isaf,</span>
<span id="cb2-617"><a href="#cb2-617" aria-hidden="true" tabindex="-1"></a>                                               <span class="at">mode =</span> <span class="st">"undirected"</span>,</span>
<span id="cb2-618"><a href="#cb2-618" aria-hidden="true" tabindex="-1"></a>                                               <span class="at">weighted =</span> <span class="cn">TRUE</span>,</span>
<span id="cb2-619"><a href="#cb2-619" aria-hidden="true" tabindex="-1"></a>                                               <span class="at">diag =</span> <span class="cn">FALSE</span>)</span>
<span id="cb2-620"><a href="#cb2-620" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-621"><a href="#cb2-621" aria-hidden="true" tabindex="-1"></a><span class="co"># Set node colors for state vs non-state</span></span>
<span id="cb2-622"><a href="#cb2-622" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(RColorBrewer)</span>
<span id="cb2-623"><a href="#cb2-623" aria-hidden="true" tabindex="-1"></a>colrs  <span class="ot">&lt;-</span> RColorBrewer<span class="sc">::</span><span class="fu">brewer.pal</span>(<span class="dv">3</span>, <span class="st">"Dark2"</span>) </span>
<span id="cb2-624"><a href="#cb2-624" aria-hidden="true" tabindex="-1"></a>network_isaf <span class="ot">&lt;-</span> <span class="fu">set_vertex_attr</span>(network_isaf, <span class="st">"type"</span>, nodes<span class="sc">$</span>label, nodes<span class="sc">$</span>sideA_nonstate)</span>
<span id="cb2-625"><a href="#cb2-625" aria-hidden="true" tabindex="-1"></a><span class="fu">V</span>(network_isaf)[<span class="st">"United States"</span>]<span class="sc">$</span>type <span class="ot">&lt;-</span> <span class="st">"center"</span></span>
<span id="cb2-626"><a href="#cb2-626" aria-hidden="true" tabindex="-1"></a>my_color_isaf <span class="ot">&lt;-</span> colrs[<span class="fu">as.numeric</span>(<span class="fu">as.factor</span>(<span class="fu">V</span>(network_isaf)<span class="sc">$</span>type))]</span>
<span id="cb2-627"><a href="#cb2-627" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb2-628"><a href="#cb2-628" aria-hidden="true" tabindex="-1"></a>deg <span class="ot">&lt;-</span> <span class="fu">degree</span>(network_isaf, <span class="at">mode =</span> <span class="st">"all"</span>)</span>
<span id="cb2-629"><a href="#cb2-629" aria-hidden="true" tabindex="-1"></a><span class="fu">E</span>(network_isaf)<span class="sc">$</span>width <span class="ot">&lt;-</span> <span class="fu">E</span>(network_isaf)<span class="sc">$</span>weight<span class="sc">/</span><span class="dv">3</span></span>
<span id="cb2-630"><a href="#cb2-630" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-631"><a href="#cb2-631" aria-hidden="true" tabindex="-1"></a><span class="co"># Visualize network</span></span>
<span id="cb2-632"><a href="#cb2-632" aria-hidden="true" tabindex="-1"></a>l <span class="ot">&lt;-</span> <span class="fu">layout_with_graphopt</span>(network_isaf,</span>
<span id="cb2-633"><a href="#cb2-633" aria-hidden="true" tabindex="-1"></a>                          <span class="at">charge =</span> <span class="dv">1</span>)</span>
<span id="cb2-634"><a href="#cb2-634" aria-hidden="true" tabindex="-1"></a><span class="in">```</span></span>
<span id="cb2-635"><a href="#cb2-635" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-636"><a href="#cb2-636" aria-hidden="true" tabindex="-1"></a><span class="fu">## Syrian War</span></span>
<span id="cb2-637"><a href="#cb2-637" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-640"><a href="#cb2-640" aria-hidden="true" tabindex="-1"></a><span class="in">```{r}</span></span>
<span id="cb2-641"><a href="#cb2-641" aria-hidden="true" tabindex="-1"></a><span class="do">## Prep</span></span>
<span id="cb2-642"><a href="#cb2-642" aria-hidden="true" tabindex="-1"></a>nodes <span class="ot">&lt;-</span> dplyr<span class="sc">::</span><span class="fu">left_join</span>(counts, parents) <span class="sc">%&gt;%</span></span>
<span id="cb2-643"><a href="#cb2-643" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(parent_name <span class="sc">==</span> <span class="st">"Syrian Civil War"</span>) <span class="sc">%&gt;%</span></span>
<span id="cb2-644"><a href="#cb2-644" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(wikidata_name, belligerent_sideA) <span class="sc">%&gt;%</span></span>
<span id="cb2-645"><a href="#cb2-645" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">count</span>(belligerent_sideA)</span>
<span id="cb2-646"><a href="#cb2-646" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-647"><a href="#cb2-647" aria-hidden="true" tabindex="-1"></a>qcodes <span class="ot">&lt;-</span> <span class="fu">read.csv</span>(<span class="fu">paste0</span>(here<span class="sc">::</span><span class="fu">here</span>(), <span class="st">"/data/aux/"</span>,<span class="st">"belligerent_list.csv"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-648"><a href="#cb2-648" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(<span class="fu">is.na</span>(ccode_wrong)) <span class="sc">%&gt;%</span></span>
<span id="cb2-649"><a href="#cb2-649" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(belligerent, ccode, cname, Qcode) <span class="sc">%&gt;%</span></span>
<span id="cb2-650"><a href="#cb2-650" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">rename</span>(<span class="at">belligerent2 =</span> belligerent,</span>
<span id="cb2-651"><a href="#cb2-651" aria-hidden="true" tabindex="-1"></a>                <span class="at">ccode2 =</span> ccode,</span>
<span id="cb2-652"><a href="#cb2-652" aria-hidden="true" tabindex="-1"></a>                <span class="at">cname2 =</span> cname,</span>
<span id="cb2-653"><a href="#cb2-653" aria-hidden="true" tabindex="-1"></a>                <span class="at">qcode2 =</span> Qcode)</span>
<span id="cb2-654"><a href="#cb2-654" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-655"><a href="#cb2-655" aria-hidden="true" tabindex="-1"></a>nodes <span class="ot">&lt;-</span> dplyr<span class="sc">::</span><span class="fu">left_join</span>(nodes, qcodes,</span>
<span id="cb2-656"><a href="#cb2-656" aria-hidden="true" tabindex="-1"></a>                          <span class="at">by =</span> <span class="fu">c</span>(<span class="st">"belligerent_sideA"</span> <span class="ot">=</span> <span class="st">"belligerent2"</span>)) <span class="sc">%&gt;%</span></span>
<span id="cb2-657"><a href="#cb2-657" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">mutate</span>(<span class="at">sideA_nonstate =</span> dplyr<span class="sc">::</span><span class="fu">if_else</span>(<span class="fu">is.na</span>(ccode2), <span class="dv">1</span>, <span class="dv">0</span>),</span>
<span id="cb2-658"><a href="#cb2-658" aria-hidden="true" tabindex="-1"></a>                <span class="at">label =</span> dplyr<span class="sc">::</span><span class="fu">if_else</span>(<span class="fu">is.na</span>(ccode2), belligerent_sideA, cname2)) <span class="sc">%&gt;%</span></span>
<span id="cb2-659"><a href="#cb2-659" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(label, belligerent_sideA, n, sideA_nonstate) <span class="sc">%&gt;%</span></span>
<span id="cb2-660"><a href="#cb2-660" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(<span class="sc">!</span>label <span class="sc">%in%</span> <span class="fu">c</span>(<span class="st">"CJTF-OIR"</span>,</span>
<span id="cb2-661"><a href="#cb2-661" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Islamic State of Iraq and the Levant"</span>,</span>
<span id="cb2-662"><a href="#cb2-662" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"International Freedom Battalion"</span>,</span>
<span id="cb2-663"><a href="#cb2-663" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Jordan, United States"</span>))</span>
<span id="cb2-664"><a href="#cb2-664" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-665"><a href="#cb2-665" aria-hidden="true" tabindex="-1"></a><span class="fu">sort</span>(<span class="fu">unique</span>(nodes<span class="sc">$</span>label))</span>
<span id="cb2-666"><a href="#cb2-666" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-667"><a href="#cb2-667" aria-hidden="true" tabindex="-1"></a><span class="co"># Prep adjacency matrix</span></span>
<span id="cb2-668"><a href="#cb2-668" aria-hidden="true" tabindex="-1"></a>actors <span class="ot">&lt;-</span> dplyr<span class="sc">::</span><span class="fu">left_join</span>(counts, parents) <span class="sc">%&gt;%</span></span>
<span id="cb2-669"><a href="#cb2-669" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(parent_name <span class="sc">==</span> <span class="st">"Syrian Civil War"</span>) <span class="sc">%&gt;%</span></span>
<span id="cb2-670"><a href="#cb2-670" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(wikidata_name, wikidata_id, belligerent_sideA) <span class="sc">%&gt;%</span></span>
<span id="cb2-671"><a href="#cb2-671" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">distinct</span>()</span>
<span id="cb2-672"><a href="#cb2-672" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-673"><a href="#cb2-673" aria-hidden="true" tabindex="-1"></a>net_actor <span class="ot">&lt;-</span> dplyr<span class="sc">::</span><span class="fu">left_join</span>(actors, nodes) <span class="sc">%&gt;%</span></span>
<span id="cb2-674"><a href="#cb2-674" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">select</span>(wikidata_name, label) <span class="sc">%&gt;%</span></span>
<span id="cb2-675"><a href="#cb2-675" aria-hidden="true" tabindex="-1"></a>  dplyr<span class="sc">::</span><span class="fu">filter</span>(<span class="sc">!</span>label <span class="sc">%in%</span> <span class="fu">c</span>(<span class="st">"CJTF-OIR"</span>,</span>
<span id="cb2-676"><a href="#cb2-676" aria-hidden="true" tabindex="-1"></a>                              <span class="st">"Islamic State of Iraq and the Levant"</span>),</span>
<span id="cb2-677"><a href="#cb2-677" aria-hidden="true" tabindex="-1"></a>                <span class="sc">!</span><span class="fu">is.na</span>(label))</span>
<span id="cb2-678"><a href="#cb2-678" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-679"><a href="#cb2-679" aria-hidden="true" tabindex="-1"></a><span class="co"># Prep network</span></span>
<span id="cb2-680"><a href="#cb2-680" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(igraph)</span>
<span id="cb2-681"><a href="#cb2-681" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-682"><a href="#cb2-682" aria-hidden="true" tabindex="-1"></a>network_syria <span class="ot">&lt;-</span> <span class="fu">as.matrix</span>(reshape2<span class="sc">::</span><span class="fu">dcast</span>(wikidata_name <span class="sc">~</span> label, <span class="at">data =</span> net_actor, length)[,<span class="sc">-</span><span class="dv">1</span>]<span class="sc">&gt;</span><span class="dv">0</span> )</span>
<span id="cb2-683"><a href="#cb2-683" aria-hidden="true" tabindex="-1"></a>network_syria <span class="ot">&lt;-</span> <span class="fu">t</span>(network_syria) <span class="sc">%*%</span> network_syria</span>
<span id="cb2-684"><a href="#cb2-684" aria-hidden="true" tabindex="-1"></a>network_syria <span class="ot">&lt;-</span> igraph<span class="sc">::</span><span class="fu">graph_from_adjacency_matrix</span>(network_syria,</span>
<span id="cb2-685"><a href="#cb2-685" aria-hidden="true" tabindex="-1"></a>                                               <span class="at">mode =</span> <span class="st">"undirected"</span>,</span>
<span id="cb2-686"><a href="#cb2-686" aria-hidden="true" tabindex="-1"></a>                                               <span class="at">weighted =</span> <span class="cn">TRUE</span>,</span>
<span id="cb2-687"><a href="#cb2-687" aria-hidden="true" tabindex="-1"></a>                                               <span class="at">diag =</span> <span class="cn">FALSE</span>)</span>
<span id="cb2-688"><a href="#cb2-688" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-689"><a href="#cb2-689" aria-hidden="true" tabindex="-1"></a><span class="co"># Set node colors for state vs non-state</span></span>
<span id="cb2-690"><a href="#cb2-690" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(RColorBrewer)</span>
<span id="cb2-691"><a href="#cb2-691" aria-hidden="true" tabindex="-1"></a>colrs  <span class="ot">&lt;-</span> RColorBrewer<span class="sc">::</span><span class="fu">brewer.pal</span>(<span class="dv">3</span>, <span class="st">"Dark2"</span>) </span>
<span id="cb2-692"><a href="#cb2-692" aria-hidden="true" tabindex="-1"></a>network_syria <span class="ot">&lt;-</span> <span class="fu">set_vertex_attr</span>(network_syria, <span class="st">"type"</span>, nodes<span class="sc">$</span>label, nodes<span class="sc">$</span>sideA_nonstate)</span>
<span id="cb2-693"><a href="#cb2-693" aria-hidden="true" tabindex="-1"></a><span class="fu">V</span>(network_syria)[<span class="st">"United States"</span>]<span class="sc">$</span>type <span class="ot">&lt;-</span> <span class="st">"center"</span></span>
<span id="cb2-694"><a href="#cb2-694" aria-hidden="true" tabindex="-1"></a>my_color_syria <span class="ot">&lt;-</span> colrs[<span class="fu">as.numeric</span>(<span class="fu">as.factor</span>(<span class="fu">V</span>(network_syria)<span class="sc">$</span>type))]</span>
<span id="cb2-695"><a href="#cb2-695" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-696"><a href="#cb2-696" aria-hidden="true" tabindex="-1"></a>deg <span class="ot">&lt;-</span> <span class="fu">degree</span>(network_syria, <span class="at">mode =</span> <span class="st">"all"</span>)</span>
<span id="cb2-697"><a href="#cb2-697" aria-hidden="true" tabindex="-1"></a><span class="fu">E</span>(network_syria)<span class="sc">$</span>width <span class="ot">&lt;-</span> <span class="fu">E</span>(network_syria)<span class="sc">$</span>weight</span>
<span id="cb2-698"><a href="#cb2-698" aria-hidden="true" tabindex="-1"></a><span class="in">```</span></span>
<span id="cb2-699"><a href="#cb2-699" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-700"><a href="#cb2-700" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-701"><a href="#cb2-701" aria-hidden="true" tabindex="-1"></a><span class="fu">## Combine all plots</span></span>
<span id="cb2-704"><a href="#cb2-704" aria-hidden="true" tabindex="-1"></a><span class="in">```{r}</span></span>
<span id="cb2-705"><a href="#cb2-705" aria-hidden="true" tabindex="-1"></a><span class="do">## Fix color matches by switching orange to purple for ISAF</span></span>
<span id="cb2-706"><a href="#cb2-706" aria-hidden="true" tabindex="-1"></a>my_color_gulf[my_color_gulf <span class="sc">==</span> <span class="st">"#D95F02"</span>] <span class="ot">&lt;-</span> <span class="st">"#7570B3"</span></span>
<span id="cb2-707"><a href="#cb2-707" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-708"><a href="#cb2-708" aria-hidden="true" tabindex="-1"></a><span class="fu">par</span>(<span class="at">mfrow =</span> <span class="fu">c</span>(<span class="dv">2</span>, <span class="dv">2</span>),</span>
<span id="cb2-709"><a href="#cb2-709" aria-hidden="true" tabindex="-1"></a>    <span class="at">mar =</span> <span class="fu">c</span>(<span class="dv">1</span>, <span class="dv">0</span>, <span class="dv">1</span>, <span class="dv">0</span>))</span>
<span id="cb2-710"><a href="#cb2-710" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-711"><a href="#cb2-711" aria-hidden="true" tabindex="-1"></a>l <span class="ot">&lt;-</span> <span class="fu">layout_with_gem</span>(network_gulf)</span>
<span id="cb2-712"><a href="#cb2-712" aria-hidden="true" tabindex="-1"></a>n_gulf <span class="ot">&lt;-</span> <span class="fu">plot</span>(network_gulf,</span>
<span id="cb2-713"><a href="#cb2-713" aria-hidden="true" tabindex="-1"></a>               <span class="at">edge.color =</span> <span class="st">"gray"</span>,</span>
<span id="cb2-714"><a href="#cb2-714" aria-hidden="true" tabindex="-1"></a>               <span class="at">vertex.shape =</span> <span class="st">"none"</span>,</span>
<span id="cb2-715"><a href="#cb2-715" aria-hidden="true" tabindex="-1"></a>               <span class="at">vertex.label.cex =</span> <span class="fl">0.7</span>,</span>
<span id="cb2-716"><a href="#cb2-716" aria-hidden="true" tabindex="-1"></a>               <span class="at">vertex.label.color =</span> my_color_gulf,</span>
<span id="cb2-717"><a href="#cb2-717" aria-hidden="true" tabindex="-1"></a>               <span class="at">layout =</span> l,</span>
<span id="cb2-718"><a href="#cb2-718" aria-hidden="true" tabindex="-1"></a>               <span class="at">main =</span> <span class="st">"Gulf War (1991)"</span>,</span>
<span id="cb2-719"><a href="#cb2-719" aria-hidden="true" tabindex="-1"></a>               <span class="at">asp =</span> <span class="dv">0</span>)</span>
<span id="cb2-720"><a href="#cb2-720" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-721"><a href="#cb2-721" aria-hidden="true" tabindex="-1"></a>l <span class="ot">&lt;-</span> <span class="fu">layout_with_graphopt</span>(network_isaf, </span>
<span id="cb2-722"><a href="#cb2-722" aria-hidden="true" tabindex="-1"></a>                          <span class="at">charge =</span> <span class="dv">1</span>)</span>
<span id="cb2-723"><a href="#cb2-723" aria-hidden="true" tabindex="-1"></a>n_isaf <span class="ot">&lt;-</span> <span class="fu">plot</span>(network_isaf,</span>
<span id="cb2-724"><a href="#cb2-724" aria-hidden="true" tabindex="-1"></a>               <span class="at">edge.color =</span> <span class="st">"gray"</span>,</span>
<span id="cb2-725"><a href="#cb2-725" aria-hidden="true" tabindex="-1"></a>               <span class="at">vertex.shape =</span> <span class="st">"none"</span>,</span>
<span id="cb2-726"><a href="#cb2-726" aria-hidden="true" tabindex="-1"></a>               <span class="at">vertex.label.cex =</span> <span class="fl">0.7</span>,</span>
<span id="cb2-727"><a href="#cb2-727" aria-hidden="true" tabindex="-1"></a>               <span class="at">vertex.label.color =</span> my_color_isaf,</span>
<span id="cb2-728"><a href="#cb2-728" aria-hidden="true" tabindex="-1"></a>               <span class="at">layout =</span> l,</span>
<span id="cb2-729"><a href="#cb2-729" aria-hidden="true" tabindex="-1"></a>               <span class="at">main =</span> <span class="st">"War in Afghanistan (2001)"</span>,</span>
<span id="cb2-730"><a href="#cb2-730" aria-hidden="true" tabindex="-1"></a>               <span class="at">asp =</span> <span class="dv">0</span>)</span>
<span id="cb2-731"><a href="#cb2-731" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-732"><a href="#cb2-732" aria-hidden="true" tabindex="-1"></a>l <span class="ot">&lt;-</span> <span class="fu">layout_with_gem</span>(network_syria)</span>
<span id="cb2-733"><a href="#cb2-733" aria-hidden="true" tabindex="-1"></a>n_syria <span class="ot">&lt;-</span> <span class="fu">plot</span>(network_syria,</span>
<span id="cb2-734"><a href="#cb2-734" aria-hidden="true" tabindex="-1"></a>                <span class="at">edge.color =</span> <span class="st">"gray"</span>,</span>
<span id="cb2-735"><a href="#cb2-735" aria-hidden="true" tabindex="-1"></a>                <span class="at">vertex.shape =</span> <span class="st">"none"</span>,</span>
<span id="cb2-736"><a href="#cb2-736" aria-hidden="true" tabindex="-1"></a>                <span class="at">vertex.label.cex =</span> <span class="fl">0.7</span>,</span>
<span id="cb2-737"><a href="#cb2-737" aria-hidden="true" tabindex="-1"></a>                <span class="at">vertex.label.color =</span> my_color_syria,</span>
<span id="cb2-738"><a href="#cb2-738" aria-hidden="true" tabindex="-1"></a>                <span class="at">layout =</span> l,</span>
<span id="cb2-739"><a href="#cb2-739" aria-hidden="true" tabindex="-1"></a>                <span class="at">main =</span> <span class="st">"Syrian Civil War (2015)"</span>,</span>
<span id="cb2-740"><a href="#cb2-740" aria-hidden="true" tabindex="-1"></a>                <span class="at">asp =</span> <span class="dv">0</span>)</span>
<span id="cb2-741"><a href="#cb2-741" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-742"><a href="#cb2-742" aria-hidden="true" tabindex="-1"></a><span class="fu">legend</span>(<span class="at">x =</span> <span class="fl">2.1</span>, <span class="at">y =</span> <span class="fl">0.6</span>,</span>
<span id="cb2-743"><a href="#cb2-743" aria-hidden="true" tabindex="-1"></a>       <span class="fu">c</span>(<span class="st">"State ally"</span>,<span class="st">"Non-state ally"</span>, <span class="st">"US"</span>),</span>
<span id="cb2-744"><a href="#cb2-744" aria-hidden="true" tabindex="-1"></a>       <span class="at">xpd =</span> <span class="cn">NA</span>,</span>
<span id="cb2-745"><a href="#cb2-745" aria-hidden="true" tabindex="-1"></a>       <span class="at">pch =</span> <span class="dv">21</span>,</span>
<span id="cb2-746"><a href="#cb2-746" aria-hidden="true" tabindex="-1"></a>       <span class="at">col =</span> <span class="st">"#777777"</span>,</span>
<span id="cb2-747"><a href="#cb2-747" aria-hidden="true" tabindex="-1"></a>       <span class="at">pt.bg =</span> colrs, <span class="at">pt.cex =</span> <span class="dv">2</span>, <span class="at">cex =</span> .<span class="dv">8</span>, <span class="at">bty =</span> <span class="st">"n"</span>, <span class="at">ncol =</span> <span class="dv">1</span>)</span>
<span id="cb2-748"><a href="#cb2-748" aria-hidden="true" tabindex="-1"></a><span class="in">```</span></span>
</code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div></div></div></div></div>
</div> <!-- /content -->



</body></html>